0

I have a problem with this code at the time of running. help me please.

using System; class ProjectEuler3{ public static void Main(){ long limit = 600851475143; int mf = 0; for (int p=1;p<10;p++){ if(limit%p==0){ mf = p; } else{continue;} } Console.WriteLine(mf); } } tells me that you are trying to divide by 0, what should I do?

3rd Jun 2022, 1:46 AM
Andrey
7 Answers
+ 1
Thank you so much.
3rd Jun 2022, 4:02 AM
Andrey
+ 1
No problem šŸ‘Œ And good luck! šŸ‘
3rd Jun 2022, 4:10 AM
Ipang
0
Are you sure you initialized <p> in the loop by 1? division by zero error shouldn't be raised unless <p> was initialized by zero.
3rd Jun 2022, 2:25 AM
Ipang
0
yes, the value of "p" is inside the loop, and I need to enter a value of 12 digits but I can not use "int" I have to use "long" but I do not know how, how would you implement it?
3rd Jun 2022, 3:08 AM
Andrey
0
Can you describe the program please? I'm not understanding what you are trying to do here ...
3rd Jun 2022, 3:09 AM
Ipang
0
I need to find the largest prime factor of 600851475143.
3rd Jun 2022, 3:15 AM
Andrey
3rd Jun 2022, 3:33 AM
Ipang