fork download
  1. class Math {
  2. static int method(int n) {
  3. if (n <= 1) {
  4. return 1;
  5. }
  6. return method(n - 2) + method(n - 1);
  7. }
  8.  
  9. public static void main(String[] args) {
  10. int number = 5;
  11. for (int i = 1; i <= number; i++){
  12. System.out.print(method(i) + " ");
  13. }
  14. }
  15. }
Success #stdin #stdout 0.1s 55632KB
stdin
Standard input is empty
stdout
1 2 3 5 8