# algorithm – Fibonacci problem in C # codability

I'm trying to solve the following problem of Codility. I only have that
37% of points (75% for accuracy and 0% for performance).

Can any one help identify the problem in my code. I found an optimal
solution (with a score of 100%) by making a small change in my code. While
by calculating the Fibonacci value, I take Modulo from Math.Pow (2,
Max_Of_B). I have commented this line in the code (please note
that in the given solution, I did not give the code of passage of the
value for Max_Of_B of the main function).

1. I did not understand how we understand that we have to do the operation '% & # 39; to keep the value less

2. I'm doing here (Fib (n-1) + Fib (n-2))% Math.Pow (2, Y). Here, Y = Max_Of_B. My doubt is how this problem should and understand that Y
= Max_Of_B. Or in other words, why did we choose Max_Of_B and not another number.

3. If I did not do '%', the performance will be affected. But how does this affect the correction.

Please see the question and my solution below

You have to climb a ladder. The scale has exactly N bars,
numbered from 1 to N. At each step, you can climb by one or two
bars. More precisely:

with your first step, you can put yourself on line 1 or 2, if you are on the line
K, you can go to the K + 1 or K + 2 ladder, finally you have to stand up
line N. Your task is to count the number of ways to climb
at the top of the scale.

For example, if N = 4, you have five different ways to climb,
ascending by:

1, 1, 1 and 1 bar, 1, 1 and 2 bars, 1, 2 and 1 bar, 2, 1 and 1
bars, and 2 and 2 bars. Given N = 5, you have eight different ways
climbing, ascending by:

1, 1, 1, 1 and 1 bar, 1, 1, 1 and 2 bars, 1, 1, 2 and 1 bar, 1, 2,
1 and 1 bar, 1, 2 and 2 bars, 2, 1, 1 and 1 bars, 2, 1 and 2 bars,
and 2, 2 and 1 bar. The number of different paths can be very large,
it is sufficient to return the result modulo 2P, for a
integer P.

Write a function:

class Solution {public int[] solution (int[] A, int[] B); }

that, given two non-empty arrays A and B of integer L, returns a
table consisting of integer L specifying consecutive responses;
the position I should hold the number of different ways to climb the
scale with A[I] steps modulo 2b[I].

For example, if L = 5 and:

``````    A[0] = 4 B[0] = 3
A[1] = 4 B[1] = 2
A[2] = 5 B[2] = 4
A[3] = 5 B[3] = 3
A[4] = 1 B[4] = 1 the function must return the sequence [5, 1, 8, 0, 1]as explained above.
``````

Write an effective algorithm for the following assumptions:

L is an integer in the interval [1..50,000]; each element of Table A
is an integer in the interval [1..L]; each element of Table B is a
whole in the beach [1..30].