Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. package asd;
  2.  
  3. /**
  4. *
  5. * @author Lukasz
  6. */
  7. public class FiboDyn {
  8.  
  9. /**
  10. * @param args the command line arguments
  11. */
  12. public static void main(String[] args) {
  13. final int N=5;
  14. System.out.println(fibo(N));
  15. }
  16. static int fibo(int n){
  17. int [] tab = new int[n+1];
  18.  
  19. tab[1]=1;
  20. tab[2]=1;
  21. for(int i=3;i<tab.length;i++)
  22. tab[i]= tab[i-1]+tab[i-2];
  23. return tab[tab.length -1];
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement