Page 7 of 7
Re: Problem 003
Posted: Wed Nov 12, 2014 5:11 pm
by Panken
Hello,
I'm also in trouble with this exercice.
My code can't found any number that can divide 600851475143.
Re: Problem 003
Posted: Wed Nov 12, 2014 6:02 pm
by mpiotte
Panken wrote:Hello,
I'm also in trouble with this exercice.
My code can't found any number that can divide 600851475143.
...
The reason is that while the question ask for a factor of 600851475143, your code uses 6851475143, a prime number.
Please don't post code on this board.
Re: Problem 003
Posted: Wed Nov 04, 2015 12:13 pm
by Salomanuel
hi there, I just started learning, so go easy on me please!
I'm using Javascript
I've printed a series of numbers till the size of mrNumber (600851475143)
then I modulo mrNumber to every number of this series, if the result is 0, I push it to an array
then I divide mrNumber by this value, (to easy the brute force process (which usually crashes everything))
lastly I pick the last number of the array
but I get a number which, while being a prime number, is not the right one (my number is 21 years before the arrival of Cristoforo Colombo)
(can I post the code without being castrated?)
Re: Problem 003
Posted: Wed Nov 04, 2015 12:35 pm
by mpiotte
Salomanuel wrote:(can I post the code without being castrated?)
No, don't post code here.
Maybe the prime factor you found is simply not the largest?
Alternatively, you could ask if someone can help you through private messages.
Re: Problem 003
Posted: Sun Mar 06, 2016 8:46 pm
by venomnert
I am using JavaScript and I am using recursion to solve the problem. I am starting from 600851475143 and work my down. First I check to see if the immediate number below 600851475143 divides 600851475143 if so check to see if that number is a prime. If it is a prime then we are done, if not repeat the process. However, I am getting an "RangeError: Maximum call stack size exceeded" error.
If someone can help me please send me a private message so I can show you my code.
Re: Problem 003
Posted: Sun Mar 06, 2016 10:27 pm
by v6ph1
Salomanuel wrote:but I get a number which, while being a prime number, is not the right one (my number is 21 years before the arrival of Cristoforo Colombo)
This is a valid prime factor of the number, but it is not the highest one.
Javascript is not the best programming language for exact calculations. - There is no type safety.
You may try to force the number to an integer type.
Re: Problem 003
Posted: Sun Mar 27, 2016 6:32 pm
by TheBonobo4
venomnert wrote:I am using JavaScript and I am using recursion to solve the problem. I am starting from 600851475143 and work my down. First I check to see if the immediate number below 600851475143 divides 600851475143 if so check to see if that number is a prime. If it is a prime then we are done, if not repeat the process. However, I am getting an "RangeError: Maximum call stack size exceeded" error.
If someone can help me please send me a private message so I can show you my code.
Wouldn't this be insanely inefficient? You'd have to check billions of numbers until you find the highest prime factor. You can easily reduce the number of numbers you need to check.
Re: Problem 003
Posted: Thu Apr 09, 2020 9:28 pm
by allemande
Problem Description needs a correction!
(sorry if this has been said before)
It reads "The prime factors of 13195 are 5, 7, 13 and 29."
Yet, 35 is a prime factor of 13195 as well.
Re: Problem 003
Posted: Thu Apr 09, 2020 9:58 pm
by DJohn
allemande wrote: Thu Apr 09, 2020 9:28 pm
"The prime factors of 13195 are 5, 7, 13 and 29."
Yet, 35 is a prime factor of 13195 as well.
To be a prime factor, a factor needs to be prime. 35 = 5*7 is not.