+ 1

if to while

how to make it just using while statement? x=int(input("Number = ")) t=0 for i in range (x+1,0,-1): if(i%2==0): t=t+1 if(i==2): print(i,end=" = ") else: print(i,end=" + ") print(t)

14th Oct 2016, 3:01 PM
Angel
Angel - avatar
4 Answers
+ 4
i = int(input("Number = ")) i = i//2*2 t = 0 while i >= 1: t += i if i > 2: print(i, end=" + ") else: print(i, end=" = ") i -= 2 print(t)
14th Oct 2016, 3:17 PM
Zen
Zen - avatar
+ 2
I tried to change your code as little as possible btw you don't have to type i=i+1 instead you can use i+=1 (anyway I changed those because I like that way more 😀) x=int(input("Number=")) t,i=0,x+1 while i>0: if i%2==0: t+=1 if i==2: print(i,end="=") else: print(i,end="+") i-=1 print(t)
14th Oct 2016, 4:00 PM
Sunera
Sunera - avatar
0
can winrar password be cracked
14th Oct 2016, 3:20 PM
Biswa baro
Biswa baro - avatar
0
Biswa baro well you can but you'll have to use a software like rar password cracker however if you don't have the slightest clue about it's password you'll have to use brute force and no matter what software you use,(specially if the password is strong) it can take a HUGE time
14th Oct 2016, 4:04 PM
Sunera
Sunera - avatar