Showing posts with label Fibonacci java. Show all posts
Showing posts with label Fibonacci java. Show all posts

Thursday, October 6, 2016

How to print fibonacci series values using java


This post will explain you about how to write fibonacci program for given 10 integer value using java

public class Fibonacci {
 
 public static void main(String[] args) {
  
  int febonacci[] = new int[10];
  febonacci[0]=0;
  febonacci[1]=1;
  for (int i = 2; i < febonacci.length; i++) {
   febonacci[i] = febonacci[i-1]+febonacci[i-2];
   
  }
  for (int i = 0; i < febonacci.length; i++) {
   System.out.print(febonacci[i]+",");
  }
  
  
 }

output:
0,1,1,2,3,5,8,13,21,34

AddToAny

Contact Form

Name

Email *

Message *