2008-09-18, 08:52 AM
JoeTang Wrote:Yeah, I did the first, fifth, and sixth on paper. I have no clue how to work with BigIntegers or prime numbers, so I gave up on number 3.
You can make the fact up on these statements:
- Every prime over 4 (that is, all primes but 2 and 3) can be written as:
6k + 1 or
6k - 1
(NB: not every number written as 6k+-1 is a prime)
- All primes but 2 is odd.
- All odd numbers are not able to divide by any number higher than the square root of the number.
Russt Wrote:For some reason, 600851475143 is a real. And trunc(600851475143) doesn't work either >_>
So I just translated my code to Javascript (which doesn't give a cucumber about variable types), stuck it in a blank HTML file, and got the right answer. Lol.
1-3, 5-7, how the heck do you do 4?
4 is easy brute force. Convert the number to an uint/byte-array and check if the first number equals the last, then the second first to the second last and so forth...

