Programming Examples

Java program to find the sum of 1st 10 numbers of Fibonacci series


Write a program to find the sum of 1st 10 numbers of Fibonacci series i.e. 1,1,2,3,5,8,13….

Fibonacci series is such a series which starting from 1 and 1, and subsequent numbers are the sum of the previous two numbers.

Solution

class Fibonacci
{
	public static void main(Strign arr[])
	{
		int i,f=1,s=0,sum=0,t;
		for(i=1;i<=10;i++)
		{
			t=f+s;
			sum+=t;
			f=s;
			s=t;
		}
		System.out.print("Sum="+sum);		
	}
}
Output

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz