Computer Science, asked by sanireddy2005pe8k5d, 1 year ago

write python program to print 1 4 7 10....40 series

Answers

Answered by chandresh126
8

Answer :

The python program to print number 1, 4, 7, ...... , 40

#include<iostream>

using namespace std;  

int main()

{

int i,a=-1,b;

for(i=1;i<=40;i+=3)

{

a*=-1;

b=i;

b*=a;

cout<<b<<" ";

}  

return 0;

}

*********************************************************


# for(i=1;i<=40;i+=3)   {You can change numbers according to series and gape}


Answered by fiercespartan
37

The common difference is 3 in the series, so all we have to do is keep adding 3 to the preceding number until we get 40. So the limit is 40.

number = 1

print(number)

while number < 40:  

 number = number + 3  

 print(number)

Hope it helps.

Similar questions