fork download
  1. import java.util.*;
  2.  
  3. class Main {
  4. public static void main(String[] args) {
  5. Scanner x = new Scanner(System.in);
  6. System.out.println("Digite a quantidade de termos");
  7. int n1 = 0, n2 = 1;
  8. for (int qtd = x.nextInt(); qtd > 0; qtd--) {
  9. System.out.print(n1 + " ");
  10. int n3 = n1 + n2;
  11. n1 = n2;
  12. n2 = n3;
  13. }
  14. System.out.println("Fim");
  15. }
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/211562/101
Success #stdin #stdout 0.12s 36088KB
stdin
10
stdout
Digite a quantidade de termos
0 1 1 2 3 5 8 13 21 34 Fim