// prime factors.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream.h"
void Factor (int number, int whichprime, int iteration);
int main(int argc, char* argv[])
{
	
	int number;
	cout<<"please enter a number";
	cin>>number;
	Factor (number,2,1);

	return 0;
}


void Factor (int number, int whichprime, int iteration)
{

	int done =0;
	int remainder;
	int restofnumber;
	
	if (number >1 )
	{
       do
	   {
		   remainder = number % whichprime;
		   if (remainder==0)
		   {
			   done = 1;
			   
			   cout<<whichprime<<endl;
			   number=number/whichprime;
		   }
		   else
		   {
			   whichprime++;
		   }
	   }while (done==0 && whichprime <number/2 );

	   if (done==1)
	   {
		   if (number>1)
		   {Factor ( number,whichprime, iteration+1);}
		   if (number==1 && iteration==1)
		   { cout <<" is a prime"<<endl;}
	   }

	   if (done==0 && iteration == 1 )
	   {
         cout<<number<< " is a prime"<<endl;
	   }


	}


}