Post
Topic
Board Services
Re: JAVA+MATH EXAM [PAYING BTC]
by
fsb4000
on 20/10/2016, 03:01:51 UTC
Code:
int closestFibonacci(int n)
{
    int current = 0;
    int next = 1;
    while (n >= next) {
        long temp = (long)current + (long)next;
        if (temp > 2147483647) {  // 2,147,483,647 - this is maximal int value
            return next;
        }
        current = next;
        next = (int)temp;
    }
    return current;
}