Advertisement
Derik_hacker

Untitled

Mar 11th, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.33 KB | None | 0 0
  1. public class Fibonacci {
  2.  
  3.     public static long[] fibonacci(int n){
  4.         long v_serie[]=new long[n];
  5.  
  6.         if(n>=1)
  7.             v_serie[0]=0;
  8.  
  9.         if(n>=2)
  10.             v_serie[1]=1;
  11.  
  12.         for(int i=2;i<n;i++){
  13.             v_serie[i]=v_serie[i-1]+v_serie[i-2];
  14.         }
  15.  
  16.         return v_serie;
  17.     }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement