Computer Science
Write a short program to print the following series :
(i) 1 4 7 10 ………. 40.
(ii) 1 -4 7 -10 ………. -40
Answer
print("First Series:")
for i in range(1, 41, 3) :
print(i, end = ' ')
print("\nSecond Series:")
x = 1
for i in range(1, 41, 3) :
print(i * x, end = ' ')
x *= -1
Output
First Series:
1 4 7 10 13 16 19 22 25 28 31 34 37 40
Second Series:
1 -4 7 -10 13 -16 19 -22 25 -28 31 -34 37 -40
Related Questions
Write a short program to check whether square root of a number is prime or not.
Write a short program to print first n odd numbers in descending order.
Write a short program to find average of list of numbers entered through keyboard.
Write a program to input 3 sides of a triangle and print whether it is an equilateral, scalene or isosceles triangle.