GO Solution For UVa 10229 - Modular Fibonacci. In this post we will see how we can solve this challenge in GoLang for UVa Online Judge.

Problem Description

The Fibonacci numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...) are defined by the recurrence:

F0 = 0

F1 = 1

Fi = Fi−1 + Fi−2 for i > 1

Write a program which calculates Mn = Fn mod 2m for given pair of n and m. 0 ≤ n ≤ 2147483647 and 0 ≤ m < 20. Note that a mod b gives the remainder when a is d

...

You can find the full details of the problem Modular Fibonacci at UVa Online Judge

Sample Input

11 7
11 6

Sample Output

89
25

Solution: Please check the main.go snippet for the solution.

Solution originally posted at: Github by @codingsince1985