Q. Write a program to generate the sequence: –5, 10, –15, 20, –25….. upto n, where n is an integer input by the user.


Answer :-


n = int(input( "Enter n :- "))

for i in range( 5, n+1 , 5):
    if i % 2 == 0:
        print(i)
    else :
        print(-i)


Output :-

Enter n :- 30
-5
10
-15
20
-25
30

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post