Need a java program

Ads
 

Need a java program

Write a code of java to print the fibonacci series.

View Answers

February 29, 2012 at 10:16 PM

for(int j=1;j<=5;j++) {
int i,a,b,c; a=1;b=1;int n=5; System.out.print("fibonicci series is " + a +" " + b +" "); for(i=1;i<=n-2;i++) {
c=a+b; b=a;a=c; System.out.print(c+" "); } System.out.println();
}


February 29, 2012 at 10:18 PM

for(int j=1;j<=5;j++)
        {       
        int i,a,b,c;
        a=1;b=1;int n=5;
        System.out.print("fibonicci series is " + a +" " + b +" ");
        for(i=1;i<=n-2;i++)
        {   
            c=a+b;
            b=a;a=c;
            System.out.print(c+" ");
        }
        System.out.println();   
        }

March 1, 2012 at 10:58 AM

import java.util.*;

public class fibbo {
public static void main(String[] args) throws Exception {
    Scanner input=new Scanner(System.in);
    System.out.print("Enter no. of terms you want to generate in series: ");
    int num = input.nextInt();
    int f1=0,f2=0,f3=1;
    System.out.println("Fibonacci Series: ");
    for(int i=1;i<=num;i++){
        System.out.println(f3);
        f1=f2;
        f2=f3;
        f3=f1+f2;
    }
  }
}

Ads









Related Tutorials/Questions & Answers:
need a java program for the following
need a java program for the following  Write a java program with three horizontal sliders. Name the sliders, the first one as red, the second one as green and the third one as blue. You design the program such that on varying
Need a java program
Need a java program  Write a code of java to print the fibonacci series.   for(int j=1;j<=5;j++) { int i,a,b,c; a=1;b=1;int n=5; System.out.print("fibonicci series is " + a +" " + b
Advertisements
I need add my java program with a picture.
I need add my java program with a picture.  Good evng Frnds Friends i created 1 jar file in my desktop. I need add this program with 1 picture. Whenever the user double clicking on that picture The program must start instead
need to Program
need to Program   Can any one help me on below How to insert more then one records in EXCEL Sheet using JSP
java program...need help as soon as possible!!! - Java Beginners
java program...need help as soon as possible!!!  Modify the Lexer (15.... 4. Print each token with line number READLINE: program { int i int j program left: 0 right: 6 line: 1 { left: 8 right: 8: line: 1 int
I really need a tutor for Java program that has to do with multithreading and gui!
I really need a tutor for Java program that has to do with multithreading and gui!  I am looking for a Tutor to help me with a Java program, specially GUI and multithreading. If you can tutor, please email me
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
need help with program
need help with program  To write a program to read a set of words from a file and return the following 1)Each word in the file against its frequency 2) the frequency should be in the descending order of the frequencies
need help with program
need help with program  To write a program where we can take two integer array as input,Find the missing number from array"B" has all the numbers from array"A" except one,and find the fastest way in doing
Need help with console program?
Need help with console program?  Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). thanks in advance.   Here is an example that repeatedly
Need help writing a console program
Need help writing a console program  I need help cant seems to figure it out! Write a program that consists of three classes. The first class will be the actual program. The second class will simply convert a string to lower
need of frameworks in java?
need of frameworks in java?  What is need of frameworks in java
need of frameworks in java?
need of frameworks in java?  What is need of frameworks in java
need of frameworks in java?
need of frameworks in java?  What is need of frameworks in java
need of frameworks in java?
need of frameworks in java?  What is need of frameworks in java
Need Help in Java programming
Need Help in Java programming  Hello. Can someone please help me with writing the following program Java program that gives assignment details such as:assignment number,assignment name,due date,submission date,percentage marks
How to Program in Java
This tutorial tells you how to program in Java? As a beginner you must know... is also used to create enterprise web applications also. To program in Java you... to write Java program. Here are the steps of programming Java: Step 1: Download
Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have... using JAVA JSP). e.g. Tool does not adjust with the resolution of the screen(need to know how I can adjust it based on the cureen system's screen resolution
what is the need of... - Java Beginners
what is the need of...   what is the need of " return type like void ?   Hi Friend, In java, method always require a return type.The main method is the client code therefore jvm does not expected any return
java program for
java program for   java program for printing documents,images and cards
Need to create a java applet
Need to create a java applet   Hi people i need to create a java applet for which there will be 2 buttons to indicate small and big. I need to make a circle. When i click small the circle should be small and when i click big
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
java program
java program  how to write an addition program in java without using arithematic operator
java program
java program  Write a java program to do matrix addition operation On two given matrices
java program
java program  write java program for constructor,overriding,overriding,exception handling
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write a java program to display array list and calculate the average of given array
Java Program
Java Program  java program to insert row in excel sheet after identifying an object
java program
java program  java program to implement the reflection of a particular class details like constructor,methods and fields with its modifiers
java program
java program  Write a java program to find the number of Positive numbers in m* n matrix
java program
java program  Write a program to create an applet and display The message "welcome to java

Ads