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

Solve 1 2/5 + 4/15 ???
12/5+4/15. ----36/15+4/15------40/15-----8/3
Divyansh
Why does an aqueous solution of acid conduct electricity?
In simpler words, this is so because an aqueous solution of water has both cations and anions in it. When two different electrodes are immersed in it and potential difference is applied across the electrodes...
Yash
0 0
7
Find the value of (sin°45- cos°45)
sin 45 - cos 45 = 0
Meenakshi
0 0
6

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

Ask a Question

Related Lessons

Square a number using the Deficiency or Yaavadunam Sutra method of vedic maths
Square a number by the Deficiency Sutra Method Rules: Rule 1 : Find the base of given number. That is maybe, 10, 100, 1000, 10000, ... Rule 2 : Find the difference between base and a given number....

How to remember the nature of 12 pairs of cranial nerves?
Trick- Some Says Money Matters But My Brother Says Big Books Matter Most. Now know the initial letter of each word written in capital. And decode them as S stands for sensory, B stands for both(mixed)...

Essential Elements of a Valid Contract
Essential Elements of a Valid Contract: (i) Agreement: In order to constitute a contract, there must be an agreement in first place. An agreement in turn is composed of two elements-offer and acceptance....
F

Difference between influence and inspire.
Some terms are frequently used by commerce students but one must be clear with the term which is using, influence and inspire is one of them which is used by students frequently but they don't know the...

Most valuable learning tip - Keep mind fresh!
Before sitting to read, keep your mind fresh. Remove all unnecessary thoughts. Then only things will get register in mind!! All the best..
C

CA. CS. Mitali Trivedi

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