-
-
Save folivetti/7551b3f29b6623cb852f660f6219522c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class Main { | |
public static double razaoAurea(){ | |
return (1.0 + Math.sqrt(5))/2.0; | |
} | |
public static int fibonacci(int n, double phi){ | |
return (int) Math.round((Math.pow(phi, n) + Math.pow(1.0 - phi, n))/Math.sqrt(5.0)); | |
} | |
public static double voceEhComum ( double braco , double meiobraco , double phi ) { | |
return Math.abs(braco/meiobraco - phi); | |
} | |
public static void main(String[] args) { | |
double phi; | |
int n, f; | |
double braco, meiobraco, diferenca; | |
Scanner leitor = new Scanner(System.in); | |
phi = razaoAurea(); | |
System . out . println ( " Phi = " + phi ) ; | |
n = leitor.nextInt () ; | |
f = fibonacci (n , phi ) ; | |
System.out.println ( "Fibonacci de " + n + " = " + f ) ; | |
System.out.println ( " Entre com a medida em cm do seu ombro ata o final de sua mao"); | |
braco = leitor.nextDouble(); | |
meiobraco = leitor.nextDouble(); | |
diferenca = voceEhComum( braco , meiobraco , phi ); | |
System.out.println ("Pessoas comuns tem diferenca zero : " + diferenca ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment