Total Pageviews

Wednesday, 6 July 2016

C program for Series - 2,3,5,3,5,8,4,7,11,5,9,14..

Input-10
Output-2 3 5 3 5 8 4 7 11 5 9 14 6 11 17 7 13 20 8 15 23 9 17 26 10 19 29

PROGRAM

#include <iostream>
using namespace std;

int main() {

int n;
cin>>n;
int count=1;
for(int i=2;i<=n;i++){
   int l = i;
   cout<<l<<" ";
   l+=count;
   cout<<l<<" ";
   count++;
   l+=count;
   cout<<l<<" ";
}
return 0;
}

OUTPUT-

No comments:

Post a Comment