Skip to content

Instantly share code, notes, and snippets.

@Baekjoon
Created April 17, 2015 09:07
Show Gist options
  • Save Baekjoon/100b05fd15f8067ebd0e to your computer and use it in GitHub Desktop.
Save Baekjoon/100b05fd15f8067ebd0e to your computer and use it in GitHub Desktop.
java biginteger fibonacci
import java.util.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
BigInteger[] f = new BigInteger[100];
f[0] = BigInteger.ZERO;
f[1] = BigInteger.ONE;
for (int i=2; i<f.length; i++) {
f[i] = f[i-1].add(f[i-2]);
}
for (int i=0; i<f.length; i++) {
System.out.println(String.format("f[%d] = %s",i, f[i].toString()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment