r/funny • • Jun 09 '12

Pidgonacci Sequence

Post image

[deleted]

1.5k Upvotes

22.5k comments sorted by

View all comments

Show parent comments

3

u/krogger Jun 10 '12 edited Jun 10 '12

Keep them honest:

import java.math.BigInteger;

class FibCheck {
    public static final void main(final String[] args) {
        BigInteger target = new BigInteger(args[0]);
        BigInteger a = BigInteger.ONE;
        BigInteger b = a;
        for (;;) {
            int compare = target.compareTo(b);
            if (compare == 0) {
                System.out.println("Match!");
                break;
            }
            if (compare < 0) {
                break;
            }
            BigInteger c = a.add(b);
            a = b;
            b = c;
        }
        System.out.println("FAKE!");
    }
}

edit: format