0
Is my outcome for this loop right?
n= 8 z= 1 for in in range (1, n, 2) if i == 6: z = z - i else: z = z*i print ("outcome:" + str( z)) my outcome: z=1 n=8 i=1 z=1 n=8 i=3 z=3 n=8 i=5 z=15 n=8 i=7 loop terminated so my outcome is 15. i dont think it is right because i heard the outcome for this loop is 105... thanks for help
4 Respuestas
+ 1
nope,
output will be 105
+ 1
Initially z= 1, and n = 8
i starts from 1
i=1
z = 1*1 = 1
i=3
z = 1*3 = 3
i=5
z = 3*5 = 15
i = 7
z = 15*7 = 105
# loop will terminates here
output:
outcome :105
#you can also print output with changing
#type of z
# use print("outcome: ",z)
0
Nikhil Dhama so how do you get 105?^^
0
Nikhil Dhama aaah yesss thank you!:)