write a program to display the series
S=1+1+2+3+5+....n
Answers
Explanation:
++ program to find sum of series
#include <iostream>
using namespace std;
// Function to return sum of
// 1/1 + 1/2 + 1/3 + ..+ 1/n
class gfg
{
public : double sum(int n)
{
double i, s = 0.0;
for (i = 1; i <= n; i++)
s = s + 1/i;
return s;
}
};
// Driver code
int main()
{
gfg g;
int n = 5;
cout << "Sum is " << g.sum(n);
return 0;
}
Answer:
Note: Note: I am using C programming language.
#include<stdio.h>
void fibo(int n)
{ int ft=0,st=1,nt,i; //ft means first term
for(i=1;i<=n;i++)
{
printf(" %d ",st); //st means second term
nt=ft+st;
ft=st;
st=nt; //nt means next term
}
}
int main()
{
int n;
printf("Enter the value of n :");
scanf("%d",&n);
fibo(n);
return 0;
}
**Please follow me and mark this ans as Branliest answer.Thank you!