UrbanPro

Take Tuition from the Best Tutors

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

Search in

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

What are the best BCA colleges in Delhi?
Amity University, Noida Jamia Millia Islamia, Delhi Maharaja Agrasen Institute of Technology, Delhi. These are some of the best colleges according to us.
P
0 0
5
How should I study Class 12 mathematics without coaching?
Solve R. D SHARMA (REFERENCE BOOK) FROM BASIC LEVEL TO HIGHER LEVEL. And YOU MUST TAKE HELP FROM YOUR SCHOOL MATHS TEACHER.
My
0 0
7
with out using ; we can print the hello world or we can not print
The C/C++ compiler uses a semicolon ';' to understand when a statement terminates. To print a string constant such as "Hello world" to any output device would require a function(printf for c/c++) , its...
Uday
What are the challenges faced by the Indian railways?
What are the problems faced in Indian Railways? Although the development of railways in our country took place rapidly, still there are numberless problems in the path of steady growth. The main problems...
Srinitha
0 0
6
How to create our database in oracle database 10g?
Have you already installed oracle on your system?
Nitish

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

Ask a Question

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