plduhoux
2/20/2018 - 1:47 AM

fibonacciIndex

int fibonacciIndex(int n) {
    if (n == 1) return 0;
    int i = 0, j = 1;
    int res = 0;
    int ind = 1;
    while (res == 0) {
        int tmp = i;
        i = i + j;
        j = tmp;
        if ((""+i).length() == n) {
            res = ind;
            break;
        }
        ind++;
    }
    return res;
}