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