0
Whi does it sais that i dumped the program
Its a practice code but it doesn't work https://code.sololearn.com/cdb63PW56ehJ/?ref=app
3 Antworten
+ 2
what its intended to do...?
+ 1
Line 7:
Notice that the loop counter <i> begins with zero
for( int i = 0; i <= num && i <= num2; i++)
Line 8:
The `if` conditional checks whether <i> was a factor of <num>, but loop counter <i> began with zero. I'm guessing <num> % 0 here *might be* the reason for the crash. It's hard for me to describe, but perhaps it had something to do with division by zero.
if( num % i == 0 ) // <i> was zero -> crash
Solution:
Initialize loop counter <i> by one rather than zero
P.S. What's the purpose of the second condition `i <= num2`?
+ 1
Thanks it work this program calculates the greatest common divisor of two numbers