| Lexington High School Mathematics | Math Dept. Front Page | Student Links | Family Links |
| Introduction to C++, Kevin Kelly | Kelly Front Page | C++ Course Guide | C++ Assignments | C++ Info |
Write a program that can factor any integer into its prime number factors.
For example, if the user enters 60 then a correct output would be
60 = 2 * 2 * 3 * 5
Your program must utilize at least one of two functions that you wrote in past assignments: prime (from Assignment 22) and divisible (from Assignment 17). Copy those functions into your new program as needed.
Here is one possible strategy you could use.
2
60
98
360
499
667
2000
14641
30330
198147
999983
1022117
1048576
897100929
899999879
899999986
360 = 2^3 * 3^2 * 5
For 5 of the 10 extension points: Choose a factoring method that works efficiently enough that your program can factor large numbers (like the three 9-digit test numbers) in less than a second (on neon, under typical conditions). If you believe you have achieved this kind of speed, demonstrate your program to me during class to receive these extension points.