i need some help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

i need some help

im making a code that add al the prime numbers up to the given number of the user, but the problem is that is not giving me the right result, for example if i introduce the number 23, the result should be 101 but the program is giving me 100. if some body know how to fix it its going to help a lot. https://code.sololearn.com/cQHJE3A1CR2S/?ref=app

16th Nov 2023, 1:58 AM
Alan Restrepo
Alan Restrepo - avatar
3 Answers
+ 8
Your code works correctly. For input 23, 100 is the correct result. 1 is not a prime.
16th Nov 2023, 4:53 AM
Tibor Santa
Tibor Santa - avatar
+ 7
And what makes you think that the result should be 101? What should be 1 in the list?
16th Nov 2023, 2:45 AM
Solo
Solo - avatar
+ 1
Tibor Santa You right, my bad I was doing the math the wrong way, thanks 👍
16th Nov 2023, 8:44 AM
Alan Restrepo
Alan Restrepo - avatar