[Tutor] project euler prime factorization problem
nblack3 at student.gsu.edu
Sun Aug 29 23:58:48 CEST 2010
"Did you test the program? That is one way to tell whether it works perfectly. What you showed above will do one visible thing - it will print "Don't forget to consider primes 2, 3, 5, and 7\n". The rest is a somewhat confusing collection of function definitions and comments. You never call the functions so nothing else will happen.
As Alan said - research prime factors to see how others approach it.
My current reasoning was something of this sort: Find all the factors of a number, then reduce them to just the prime factors
Very inefficient. IMHO the proper way is to generate a list of all the prime numbers up to the square root of 600851475143, then test each (starting with the largest and working down) till you discover a factor. That then is the answer.
There are many published algorithms for generating primes.
and you can then multiply them together to get that number thus having the prime factors. I need a lot of help haha. Thanks in advance everyone. If anyone has a good resource to point me to other than the open book project and dive into python it would be much appreciated. Would it be useful for me to buy a book, and if so what are some easily accessible ones? I feel dive into python is just too advanced for me. I understand a lot of the teachings, but the examples seem unwieldy and esoteric.
Yeah, thanks everyone for the comments. I will follow your advice Bob. I didn't call the
functions in the program because I was calling them myself in the interpreter after running it. I
don't know if that is the way everyone else programs, but I just write it in idle and save it and run
it over and over making sure it is doing what I want
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor