Write a program for series 0,1,1,2,4,8,16,32
Answers
Answered by
5
0, 1, 1, 2, 4, 8, 16, 32
The above sequence has a factor of 2 between each number.
Each term (except the first 3 terms) is found by multiplying the previous term by 2.
Code as followed :
print(0,1, end=" ") #I'll first print the first 2 numbers as it is not in a pattern.
a = 1 #Taking a variable with value 1 for changing its value in the while loop.
while a<= 33:
print(a, end=" ")
a *= 2 #This will change the value of a by multiplying all the value of a by 2.
Attachments:
Similar questions
Social Sciences,
6 months ago
Social Sciences,
6 months ago
Biology,
1 year ago
English,
1 year ago
Math,
1 year ago