+ 1

Help with a python code

I have tried to make a computer program to check which number till n are firsts, but from some reason, it print me all numbers instead of all the firsts. Can you help me? Here is a link: https://code.sololearn.com/c0rCUeTyvol1/#py Thanks!

31st Jul 2017, 9:36 AM
ayal matas
4 Answers
+ 2
Because your print-statement belongs to the "for f in range(number)" loop according to the indent - for this reason it is executed as often as this for-loop runs. If you want it to belong to the inner for-loop: give it more indent
31st Jul 2017, 9:47 AM
Martin Ed
Martin Ed - avatar
+ 2
but then it tells me: No output...
31st Jul 2017, 9:52 AM
ayal matas
+ 2
If there is no ouput, then there is something wrong with the logic of your code - but the reason why all numbers were shown was the definitely the wrong indent. What are you actually trying to achive? What are the "firsts" of a number?
31st Jul 2017, 10:42 AM
Martin Ed
Martin Ed - avatar
+ 2
Firsts number is a number which is divisible only by himself and one.
31st Jul 2017, 10:46 AM
ayal matas