Skip to content

Instantly share code, notes, and snippets.

@takanakahiko
Created January 2, 2015 14:54
Show Gist options
  • Save takanakahiko/b636dcc92a421cd79bec to your computer and use it in GitHub Desktop.
Save takanakahiko/b636dcc92a421cd79bec to your computer and use it in GitHub Desktop.
フィボナッチ数列のn番目とn+1番目の比率が黄金比に収束するやつ(1.2)
public class GoldenMean {
public static void main (String[] args) {
int a = 1;
int b = 1;
int c;
for(int i = 0; i < 30; i++){
System.out.println(i+"\ta="+a+"\tb="+b+"\tb/a="+((double)b/a));
c = a + b;
a = b;
b = c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment