# Prime and Factor problem...

view full story

http://www.daniweb.com – Here is the prompt for my assignment Your third assignment is to write a C++ program that will print out the primes numbers between 2 and 100. However, you must use two functions in your program. The first function, factor, takes an int, n, and returns two factors of n whose product is n. For example, if n is 36, factor could return 6 and 6 (or 2 and 18, or 4 and 9, ...). If n is prime, factor should return 1 and n (in that order). If n is not prime, factor should not return 1 and n, but find two non-trivial factors. The factor function should have a return type of void and use call-by-reference parameters to return the two factors. The second function, prime, should return a Boolean value - true if the argument is prime, and false if it is not prime. Since a good programmer is lazy, the prime function should call the factor function instead of doing any work itself. Finally, the main program should loop through all the numbers between 2 and 100, and print out just those that are prime. The main program should call the prime function appropriately, which in turn calls the factor function. _____________________________________________ I think I'll be able to figure out how to find the prime numbers, but I have no clue how to find factors of a number (General)