Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Project Euler
#9
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...
Reply


Messages In This Thread
Project Euler - by Nikkey - 2008-09-16, 05:47 PM
Project Euler - by IsaacGS - 2008-09-16, 07:36 PM
Project Euler - by Fiel - 2008-09-16, 07:37 PM
Project Euler - by Horusmaster - 2008-09-16, 09:35 PM
Project Euler - by Russt - 2008-09-16, 10:58 PM
Project Euler - by Nikkey - 2008-09-17, 01:55 AM
Project Euler - by JoeTang - 2008-09-17, 09:40 PM
Project Euler - by Russt - 2008-09-18, 05:15 AM
Project Euler - by Nikkey - 2008-09-18, 08:52 AM
Project Euler - by Kiley - 2008-09-20, 11:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)