write python program to print 1 4 7 10....40 series
Answers
Answered by
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
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
Geography,
7 months ago
Science,
7 months ago
India Languages,
1 year ago
Math,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago
History,
1 year ago