A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
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.
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)
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.
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.
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.