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

Why targeted anti poverty programmes are conducting by the government?
To remove poverty in the country so that country may develop
Chittaranjan
0 0
6
what is the good way of studying english language ?
English has four skills listening,speaking,reading and writing..if you want to learn english then first listen,then learn the new words and use it,after that try to read books,magaxines,novels or anything...
Arzu
What is the equation of tangent and its slope form?
m= the slope of the tangent= dy/dx Tangent A: y= mx + square root( square of (am) + square of b), where m=the slope of the tangent=dy/dx or at (x1, y1), xx1/square of a + yy1/square of b=1. c = sqrt (a*a*m*m + b*b).
Chitra
0 0
8
Consider ?ACB, right-angled at C, in which AB = 29 units, BC = 21 units and ?ABC = ?. Determine the values of i. cos 2? + sin2?, ii. cos2? – sin2?.
For right angle triangle use pythagorous theorem (AC)^2 = (AB)^2 + (BC)2 PUT value of all find answer
Renu
kya aap ke pass koi job mil sakti hai 12th pass kiya h
MNC is the best for you..try it..good luck
Zakir

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

Ask a Question

Related Lessons

Basic Maths Symbols
This is a list of commonly used Basic Math Symbols in the stream of mathematics. Symbol Symbol Name Meaning / definition Example ≠ not equal sign inequality 5 ≠...
A

Amrtha S.

0 0
0

How To Increase Your Knowledge In Stock Of Words.
Standing in the cat and rat race situation of our career, it is necessary to possess a good communication skill. The base must be developed since childhood days. Knowledge about using words in correct...

Why is the Hadoop essential?
Capacity to store and process large measures of any information, rapidly. With information volumes and assortments always expanding, particularly from web-based life and the Internet of Things (IoT), that...

NLP (Neuro Lingustic Programming) & Purpose of Communication
NLP (Neuro-Linguistic Programming) & Purpose of communication What is NLP? NLP (Neuro-Linguistic Programming) is a simple and skilful method to understand what is going on inside the mind of a person,...

E-Commerce-- a short note!!
Electronic commerce is an emerging model of new selling and merchandising tools in which buyers are able to participate in all phases of a purchase decision, while stepping through those processes electronically...
K

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