0

# I need to find pairs of primes, the distance between which is two. why does the program stop working for numbers greater than 19

https://code.sololearn.com/c0RIzzWSW2C0/?ref=app

3rd Nov 2020, 9:28 AM
Vika Ustinova + 1
for (d=2; d <= Math.sqrt(b); d++){ if (b%d==0) //when d=2 never running thus if {k=1; break; } for (d=2; d <= Math.sqrt(b+2); d++){ if ((b+2)%d==0) {l=1; break; }} //after this loop d = 3 ,runn8ng for d=2,3 repeatedly //and going back to above loop.. //d=4 <Math.sqrt(b) is true and again 2nd loop repeating f9r d=2,3 so infinite looping here..
3rd Nov 2020, 11:23 AM
Jayakrishna 🇮🇳
+ 1
the variable i never got value 6, so server stops executing of this code while (i < (a-1)) { // i 0..6 i=5, b=19, sqb=4.358898943540674, d=2 i=5, b=19, sqb=4.358898943540674, d=4 i=5, b=19, sqb=4.358898943540674, d=4 i=5, b=19, sqb=4.358898943540674, d=4
3rd Nov 2020, 10:58 AM
zemiak
0
It says why, you just have to scroll down in output. It times out. That is a limitation of sololearn. As an advice you should indent your code properly and follow basic guidelines. Makes it easier to read for everybody, including yourself
3rd Nov 2020, 10:04 AM
Benjamin Jürgens 0
i tried to run it in other program on pc and it just stops on 19 without any notiffications
3rd Nov 2020, 10:06 AM
Vika Ustinova 