Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Fibonacci {
- int calcFibo(double var) {
- if (var == 0)
- return 0;
- else if (var == 1)
- return 1;
- else
- return calcFibo(var - 1) + calcFibo(var - 2);
- }
- public static void main(String[] args) {
- Fibonacci fibo = new Fibonacci();
- //Printing the first ten elements of the series
- for (int i = 0; i < 10; i++) {
- int series = fibo.calcFibo(i);
- System.out.println(series);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment