How do you run the sieve of sundaram algorithm | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0
10th May 2020, 12:43 PM
IKHWAN HABIBI
IKHWAN HABIBI - avatar
1 Answer
+ 2
Line 14: for (x = 1; ; x++) { This loop has no end contiditon. You are using break statements inside the loop. I think you should check every condition which leads to a break statement. The loop in line 30 is also critical. The end condition of this loop is p < primes.size() But inside the loop you are adding values to primes. Means, primes.size() gets larger -> infity loop
10th May 2020, 1:12 PM
Denise Roßberg
Denise Roßberg - avatar