1. /**
  2. *
  3. * Beschreibung
  4. * Gibt Fibonacci Reihe bis 100 aus
  5. * @version 1.0 vom 02.03.2012
  6. */
  7. public class fibonacci
  8. {
  9. public static void main(String[] args)
  10. {
  11. System.out.println("Hier sehen sie die Fibonacci-Reihe von 1-100:");
  12. for (int n=1;n<=11;n++)
  13. {
  14. System.out.println(fibonacci(n));
  15. }
  16. }
  17. static int fibonacci(int n)
  18. {
  19. if (n<=2)
  20. {
  21. return 1;
  22. } else
  23. {
  24. return fibonacci(n-1)+fibonacci(n-2);
  25. }
  26. }
  27. }

goto line:
Compare with:
text copy window edit this code post new code