+ 2
What is wrong here ?
n=int(input()) c=0 for i in range(1,n+1): for j in range(1,i+1): if i%j==0: c+=1 if c==2: print(i)
7 Respuestas
+ 14
Your code is functional, but it's difficult to see what your goal is.
j being always <= i,
i%j always =0
so if your input is 2 or more, you'll have:
i=1 --> j iters 1 => c=1
i=2 --> j iters 1,2 => c=3
and then c will keep growing,
c will never be = 2
and thus nothing will ever be printed
+ 7
You probably want to indent the last two lines (and fix your indentation in general)
+ 6
Diego
It helped
Thanks alot
+ 4
Fix your indentation and move "c = 0" after the first "for" loop.
n = int(input())
for i in range(1,n+1):
c = 0
for j in range(1,i+1):
...
+ 4
Okay wait I will try
+ 3
I didn't see that it's value wasn't renewing
+ 3
Thanks anyway