Android examples for java.lang:Math
Get fibonacci
//package com.java2s; import java.math.BigInteger; import java.util.ArrayList; public class Main { private static ArrayList<BigInteger> fibCache = new ArrayList<BigInteger>(); public static BigInteger fibonacci(int n) { if (n >= fibCache.size()) { fibCache.add(n, fibonacci(n - 1).add(fibonacci(n - 2))); }//from ww w . j a v a 2 s .c o m return fibCache.get(n); } }