1. public class naloga_1 {
  2. public static void main(String[] args) {
  3. int n = 0;
  4.  
  5. try {
  6. String niz = javax.swing.JOptionPane.showInputDialog("Koliko števil Fibonaccijevega zaporedja želiš generirati?");
  7. n = Integer.valueOf(niz).intValue();
  8. } catch(Exception e) {
  9. System.exit(0);
  10. }
  11.  
  12. int[] stevila = new int[n];
  13.  
  14. for(int i = 0; i < n; i++) {
  15. if(i <= 1) {
  16. stevila[i] = 1;
  17. } else {
  18. stevila[i] = stevila[i - 2] + stevila[i - 1];
  19. }
  20. System.out.print(stevila[i] + ", ");
  21. }
  22.  
  23. System.exit(0);
  24. }
  25. }