Write a python to print the 0,0,7,6,14,12,21,18, 28 series

 Write a python to print the 0,0,7,6,14,12,21,18, 28 series

Series:- 0,0,7,6,14,12,21,18, 28 .....

from this we can conclude that
i . if the index of the no is odd then add 7
ii. if the index of the no is even then add 6
0 , 0 , 0+7 ,0+6, 7+7 , 6+6,........


Code:-

no_of_elements = int(input('enter the number of elements in the series: '))
x=0
y=0
print(x)
print(y)
for i in range(1,no_of_elements+1):
    #if the index of the no is odd then add 7
    if(i%2!=0):
        x= x+7
        print(x)
    #if the index of the no is even then add 6
    else:
        y = y+6
        print(y)


Output:-





Post a Comment

0 Comments