All pastes #734544 Raw Edit

Miscellany

public java v1 · immutable
·published 2007-10-12 20:17 UTC
rendered paste body
package prog;import javax.swing.*;public class Fibonnaci {	public void nrecursivo() {		int x = 0;		int y = 1;		int b = 1;		int n = Integer.parseInt(JOptionPane.showInputDialog("Digite o valor de parada !"));				for (int i = 0; i <= n; i++) {			System.out.println(x + ",");			b = x;			x = x + y;			y = b;			if (x > n) {				break;			}		}	}	public static long fib(int n) {		if (n <= 1)			return n;		else			return fib(n - 1) + fib(n - 2);	}	public void recursivo() {		int n = Integer.parseInt(JOptionPane.showInputDialog("Especifique o numero de termos que deseja:"));		for (int i = 1; i <= n; i++)			System.out.println(i + ": " + fib(i));	}}