Problem 003

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


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
Panken
Posts: 1
Joined: Wed Nov 12, 2014 11:07 am

Re: Problem 003

Post by Panken »

Hello,

I'm also in trouble with this exercice.
My code can't found any number that can divide 600851475143.

Code: Select all

<removed by moderator>
Image
User avatar
mpiotte
Administrator
Posts: 1961
Joined: Tue May 08, 2012 5:40 pm
Location: Montréal, Canada

Re: Problem 003

Post 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.
Image
Salomanuel
Posts: 1
Joined: Wed Nov 04, 2015 12:01 pm

Re: Problem 003

Post 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?)
User avatar
mpiotte
Administrator
Posts: 1961
Joined: Tue May 08, 2012 5:40 pm
Location: Montréal, Canada

Re: Problem 003

Post 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.
Image
venomnert
Posts: 2
Joined: Fri Mar 04, 2016 7:34 pm

Re: Problem 003

Post 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.
v6ph1
Posts: 134
Joined: Mon Aug 25, 2014 7:14 pm

Re: Problem 003

Post 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.
Image
TheBonobo4
Posts: 17
Joined: Sun Jul 12, 2015 9:51 pm

Re: Problem 003

Post 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.
Image
allemande
Posts: 1
Joined: Thu Apr 09, 2020 9:23 pm

Re: Problem 003

Post 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.
DJohn
Posts: 90
Joined: Sat Oct 11, 2008 12:24 pm

Re: Problem 003

Post 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.
Post Reply