hey all
well i was trying to write some code that would output the first 20 fibonacci numbers, but im having some trouble when i impliment it. whenever i try to run the program (java fibonacci 20) it gives me this error:
Exception in thread "main" java.lang.NoSuchMethodError: main
any help will be appreciated!
here's the code (its a little weird i guess im still learning the language):
import java.util.*;
public class fibonacci {
public void main (String args[]) {
int input = Integer.parseInt(args[0]);
int result = fibonacci(input);
System.out.println(result);
}
public int fibonacci(int x) {
int a;
int b;
b = 1;
while (x > 0) {
a = 0;
a = a + b;
b = a ;
System.out.println(b);
x = x - 1;
}
return 0;
}
}
well i was trying to write some code that would output the first 20 fibonacci numbers, but im having some trouble when i impliment it. whenever i try to run the program (java fibonacci 20) it gives me this error:
Exception in thread "main" java.lang.NoSuchMethodError: main
any help will be appreciated!
here's the code (its a little weird i guess im still learning the language):
import java.util.*;
public class fibonacci {
public void main (String args[]) {
int input = Integer.parseInt(args[0]);
int result = fibonacci(input);
System.out.println(result);
}
public int fibonacci(int x) {
int a;
int b;
b = 1;
while (x > 0) {
a = 0;
a = a + b;
b = a ;
System.out.println(b);
x = x - 1;
}
return 0;
}
}