Computer Science, asked by sudeepsati488, 3 months ago

Write a program to find the sum of the numbers in the
following series:
1 4 10 19 34 52 73 100 ... N
Example if the value for N is 105, then the sum is 293
Note : Print only the output number. If the sum is 293,
then print only 293​

Answers

Answered by chintamanbhamre000
0

Answer:

Program to print the series 1, 3, 4, 8, 15, 27, 50… till N terms

Given a number N, the task is to print the first N terms of the following series:

1, 3, 4, 8, 15, 27, 50…

Examples:

Input: N = 7

Output: 1, 3, 4, 8, 15, 27, 50

Input: N = 3

Output: 1, 3, 4

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach: From the given series we can find the formula for Nth term:

1st term = 1, 2nd term = 3, 3rd term = 4

4th term = 1st term + 2nd term + 3rd term

5th term = 2nd term + 3rd term + 4th term

6th term = 3rd term + 4th term + 5th term

.

.

so on

Answered by ssc9314313552
0

Answer:

#include<iostream>

using namespace std;

int main()

{

int n,count=0;

cin>>n;

int num=1,sum=0;

for(int i=1;num<n;i++)

{

 if(i%4!=0)

 {

  sum+=num;

  num=num+3*i;

 }

 cout<<num<<" ";

}

cout<<sum;

}

Explanation:

As you can see every term increasing by 3 multiple but in every 4th case it is increasing by 6+

Similar questions