UrbanPro

Take Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

java program to print fibonacci series

 

Asked by Last Modified  

61 Answers

Learn Tuition

Follow 22
Answer

Please enter your answer

Experienced Teacher in Mathematics and Physics for class 9 to class 12.

The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... public class Fibonacci { public static void main(String args) { int n = 10, t1 = 0, t2 = 1; System.out.print("First " + n + " terms: "); for (int i = 1; i <= n; ++i) { System.out.print(t1...
read more
The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
public class Fibonacci {

    public static void main(String[] args) {

        int n = 10, t1 = 0, t2 = 1;
        System.out.print("First " + n + " terms: ");

        for (int i = 1; i <= n; ++i)
        {
            System.out.print(t1 + " + ");

            int sum = t1 + t2;
            t1 = t2;
            t2 = sum;
        }
    }
}
read less
Comments

Er. Arun Kumar(B.Tech/CSE) - Software Trainer Since 2014

class Fibonacci { public static void main(String args) { int i = 1, n = 10, t1 = 0, t2 = 1; System.out.print("First " + n + " terms: "); while (i <= n) { System.out.print(t1 + " "); int sum = t1 + t2; t1 = t2; t2 = sum; i++; } }}
read more

class Fibonacci {

public static void main(String[] args) {

int i = 1, n = 10, t1 = 0, t2 = 1;
System.out.print("First " + n + " terms: ");

while (i <= n)
{
System.out.print(t1 + " ");

int sum = t1 + t2;
t1 = t2;
t2 = sum;

i++;
}
}
}

read less
Comments

Teacher at renowned school,Janta Vidyalaya(Affiliated to CBSE Board)

public class Fibonacci { public static void main(String args) { int i = 1, n = 10, t1 = 0, t2 = 1; System.out.print("First " + n + " terms: "); while (i <= n) { System.out.print(t1 + " + "); int sum = t1 + t2; ...
read more

 

public class Fibonacci {

    public static void main(String[] args) {

        int i = 1, n = 10, t1 = 0, t2 = 1;
        System.out.print("First " + n + " terms: ");

        while (i <= n)
        {
            System.out.print(t1 + " + ");

            int sum = t1 + t2;
            t1 = t2;
            t2 = sum;

            i++;
        }
    }
}

read less
Comments

public class Fibonacci { public static void main(String args) { int n = 10, t1 = 0, t2 = 1; System.out.print("First " + n + " terms: "); for (int i = 1; i <= n; ++i) { System.out.print(t1 + " + "); int sum = t1 + t2; ...
read more
public class Fibonacci {

    public static void main(String[] args) {

        int n = 10, t1 = 0, t2 = 1;
        System.out.print("First " + n + " terms: ");

        for (int i = 1; i <= n; ++i)
        {
            System.out.print(t1 + " + ");

            int sum = t1 + t2;
            t1 = t2;
            t2 = sum;
        }
    }
}
read less
Comments

Electrical engineer and quantitative aptitude trainer with 3 years experience

class FibonacciExample1{ public static void main(String args) { int n1=0,n2=1,n3,i,count=10; System.out.print(n1+" "+n2);//printing 0 and 1 for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed { n3=n1+n2; System.out.print("...
read more
  1. class FibonacciExample1{ 
  2. public static void main(String args[])  
  3. {    
  4.  int n1=0,n2=1,n3,i,count=10;    
  5.  System.out.print(n1+" "+n2);//printing 0 and 1    
  6.     
  7.  for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed    
  8.  {    
  9.   n3=n1+n2;    
  10.   System.out.print(" "+n3);    
  11.   n1=n2;    
  12.   n2=n3;    
  13.  }    
  14.   
read less
Comments

public class Fibonacci { public static void main(String args) { int n = 10, t1 = 0, t2 = 1; System.out.print("First " + n + " terms: "); for (int i = 1; i <= n; ++i) { System.out.print(t1 + " + "); int sum = t1 + t2; t1 = t2; t2 = sum; } } }
read more

public

class Fibonacci

{

public static

void main(String[] args)

{ int n = 10, t1 = 0, t2 = 1;

System.out.print("First " + n + " terms: ");

for (int i = 1; i <= n; ++i) { System.out.print(t1 + " + ");

int sum = t1 + t2; t1 = t2; t2 = sum;

}

}

}

 
read less
Comments

Machine Learning Intern Previously worked as Full Stack Java Developer with 2 years exper.

Class start Main function start Define variable S1,S2 , n; Inside Loop Sum = S1 + S2 Print S1 '+' sum End loop End main End class
Comments

Core java learn you can ping me
Comments

public class Fibonacci { public static void main(String args) { int n = 10, t1 = 0, t2 = 1; System.out.print("First " + n + " terms: "); for (int i = 1; i <= n; ++i) { System.out.print(t1 + " + "); int sum = t1 + t2; ...
read more
public class Fibonacci {

    public static void main(String[] args) {

        int n = 10, t1 = 0, t2 = 1;
        System.out.print("First " + n + " terms: ");

        for (int i = 1; i <= n; ++i)
        {
            System.out.print(t1 + " + ");

            int sum = t1 + t2;
            t1 = t2;
            t2 = sum;
        }
    }
}
read less
Comments

import java.util.*; class Main { public static void main(String arg) { Scanner sc=new Scanner(System.in); int n=sc.nextInt();//enter total numbers in series int a=sc.nextInt();//enter the first number int b=sc.nextInt();//enter the second number ...
read more
import java.util.*;
class Main
{
    public static void main(String arg[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();//enter total numbers in series
        int a=sc.nextInt();//enter the first number
        int b=sc.nextInt();//enter the second number
        System.out.print(a+" "+b+" ");
        for(int i=1;i<n-1;i++)
        {
            int c=a+b;
            a=b;
            b=c;
            System.out.print(c+" ");
        }
    }
}
read less
Comments

View 59 more Answers

Related Questions

Is coaching important for the class 12 science exam?
No need. The thing is you must have basics and be upto date in reading and learning. Just need a compressuve reading of lessons as many times as possible and practice bits questions. It is enough to get good result.
Mrinal Kanti
0 0
5
Which country was known as the bread basket of the world during 19th century?
The United States Of America was known as the bread basket of the world during 19th century.
Thimma
0 0
6
Biology Question for students of Class 7 : a) What are chromatin fibres ? What happens to these during cell division ? b) What is thigmotropism. Give one example. by A Mathew
a) In the nucleus, the DNA double helix is packaged by special proteins (histones) to form a complex called chromatin. The chromatin undergoes further condensation to form the chromosome.Basic association...
Anita
Why people are more attracted to Private sector rather than Public sector organisations for the sake of getting a job?
Firstly this is not completely true, there are many who prefer jobs in public sector, because it more secured. On the other hand private sectors often offer better pay packages.
Monica
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

C program for Beginners
A Program to print 2 integer value. #include<stdio.h> #include<conio.h> main() int a,b,add; a=5; b=3; add=a+b; printf(“ Addition=%d”,&add); getch(); Brief description...
P

Qualitative Characteristics Of Financial Information
Qualitative characteristics are the attributes that make financial information useful to users. For Analytical purposes, Qualitative characteristics can be differentiated into Fundamental and Enhancing...

Nutrients
Definition Nutrients are the important chemicals which are required by our body Types of nutrients Carbohydrates Fats Proteins Vitamins Minerals Note* Carbohydrates and fats are called...

How To Prepare For Viva Voce Of Lab Experiments/Project Presentations?
Instruction to B.Tech/M.Tech/B.Pharm/M.Pharm/M.Sc/B.Sc/MBBS/BDS/MDS/LLB/LLM students on Lab/Project Viva voce: No tension, only attention. Prepare for viva as if the examiner is an expert in your project/lab...

Java 9 , the new beginning
Java 9 is here! A major feature release in the Java Platform Standard Edition is Java 9 Lets see what more it offers more than its previous versions Java platform module JEP 223 : New version...
G

GCC

0 0
0

Recommended Articles

With the current trend of the world going digital, electronic renaissance is a new movement that is welcomed by the new generation as it helps makes the lives of millions of people easier and convenient. Along with this rapidly changing movement and gaining popularity of Internet, e-Learning is a new tool that emerging...

Read full article >

Learning for every child starts from a very young age. While the formal methods include school curriculums and private lessons, the informal methods include dancing, music, drawing, and various fun-filling activities. Playing games and practising these types of activities helps the children get out of boredom and...

Read full article >

Appearing for exams could be stressful for students. Even though they might have prepared well, they could suffer from anxiety, tension etc. These are not good for their health and mind. However, following a few exam preparation tips can save them from all these and help them to score good marks. Let’s find out all...

Read full article >

E-learning is not just about delivering lessons online. It has a much broader scope that goes beyond manual paper or PowerPoint Presentations. To understand the reach of E-learning and how the whole process works in developing the Educational system, we will discuss a few points here. Let us find out how this new learning...

Read full article >

Looking for Tuition ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Tuition Classes?

The best tutors for Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take Tuition with the Best Tutors

The best Tutors for Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more