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

Which is the best IIT JEE coaching institute for home coaching?
How coaching institute provides home coaching?
Nikita
0 0
6

Can I be a part time Home tutor? I love teaching and can dedicate 3 hours on weekends for 4th standard to 8th standard students.

Yes dear offcourse. You just need to have the root knowledge about the subject you're interested, endless passion and good patience level for your students.
Sreesyam Sree
what is the earth diameter?
its 12,742 km..
Kotwal K

"व्रतनिधिः '' का क्या अर्थ है |

It's means varth nidi puja path Karne ki vidhi it means procedure of rituals and customs of any kind of worship to god
Rachna

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

Ask a Question

Related Lessons

How to read
Read a topic 4 times. When you read do not think about others. Now close your eye and think what you learn. Once write the topic what you read.

Rajiv Kumar

0 0
0

Types of forces and moments of force
A free body diagram is a diagram showing all the forces and moments of forces acting on an object. We distinguish between two types of objects: 1. Particles that have no spatial extent and thus have no...

Memorizing the Balance Sheet
Liability Side Soman Rocked Sajan Under Coconut Palm Soman - Share Capital Rocked - reserves & Surplus Sajan - Secured Loans Under - Un Secured Loans Coconut - Current Liabilities Palm - Provisions ...

Bonus Issue
Bonus means Issue of Shares by a Company without any consideration. Bonus Issue: It is an additional dividend given to the shareholders that can be in cash or in the form of stock. When companies have...
F

How To Write An Assignment?
Instructions for writing the Assignment: It should contain minimum of 7 pages to maximum of 10 pages. Write all the topics with clear headings, sub headings and points with serial numbers 1,2,3,4,5...

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