There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
originally posted by fred rosenberger
HOWEVER, what you are missing is that 2 goes in TWICE... so when you divide 28/2, you get 14, which is not prime... but you're never gonna find (28/2)/2 (or 28/4) to get your 7.
originally posted by fred rosenberger
OR, after you check a prime that divides evenly, check to make sure it doesn't go in again and continue with the quotient each time..
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
originally posted by fred rosenberger
If you always try and find the smallest factor first, when you're done, you're left with the largest prime factor of the original.
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Straws are for suckers. Now suck on this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|