
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pkg5.pkg11.pkg3;
import java****.BufferedReader;
import java****.InputStreamReader;
import java****.Console;
import java********Exception;
public class Principal {
private static int seg;
/**
Programa desenvlvido por wallyson Marcos
* 06/04/2013
*/
public static void main(String[] args) throws IOException {
BufferedReader entrada;
entrada = new BufferedReader(new InputStreamReader(System.in));
long Fn=0;
long Fn1=1;
long b=1;
long ent;
long cont = 0;
int opc ;
try{
System.out.println("||=========================Menu of project===============================||");
System.out.println("||Enter 1 to determine how far will the nth Fibonacci number. ||");
System.out.println("||Enter 2 to determine the count of the number nth. ||");
System.out.println("||==================================================================||");
opc = Integer.parseInt(entrada.readLine());
switch(opc)
{
case 1:{
System.out.println("Enter a number to determine how far will the nth Fibonacci number");
ent = Integer.parseInt(entrada.readLine());
System.out.println("Its sequel: ");
for(int i=2;i<=1000;i++){
System.out.println(Fn+";");
b=Fn;
Fn=Fn+Fn1;
Fn1=b;
if(Fn>ent){break;
}
}
break;
}
case 2:{
System.out.println("Enter a number to determine the count of the number nth. : ");
ent = Integer.parseInt(entrada.readLine());
System.out.println("Its sequel: ");
for(int i=1;i<=ent;i++){
System.out.println(Fn+";"+" Contador: "+i);
b=Fn;
Fn=Fn+Fn1;
Fn1=b;
}
}
break;
default:
System.out.println("Enter the correct option!");
}
} catch (Exception e){
System.out.println("Enter a correct value!");
}
}
}
public class Fibonacci{
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int opt;
// menu with the 2 options here.
if(opt == 1){
int ent = scanner.nextInt();
System.out.println(fib(ent));
}else{
System.out.println(fib(1000));
}
}
public static long fib(long n){
long ret=0;
if(n==0 || n==1){
ret = pos;
}else{
ret = fib(pos-2)+fib(pos-1);
}
return ret;
}
}