View Single Post
Old Nov 1st, 2006, 10:44 PM   #23
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 115
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Little late, but I think this one works. Got it all on my own in about a half hour. Not commented cause I didn't get lost and probably would if I commented. It's pretty simple anyway

#include <iostream>
#include <cstdlib>

int n = 1;
int count = 1;

void prime(int x)
{

	std::cout << x << "'s factors: ";
	for (; n <= x/2; n++)
	{
		if (x%n==0)
		{
			std::cout << n << " ";
			if (n > 1)
				count++;
		}

	}
	if (count >= 2)
		std::cout << std::endl << x << " is not prime";
	else
		std::cout << std::endl << x << " is prime";
}

int main()
{
	int x;
	std::cout << "Enter number: ";
	std::cin >> x;
	prime(x);
	std::cout << std::endl;
	system("pause");
}
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote