How Many Calls?
The Fibonacci numbers are defined by the following recurrence:
But we're not interested in the Fibonacci numbers here. We would like to know how many calls does it take to evaluate the n-th Fibonacci number if we follow the given recurrence. Since the numbers are going to be quite large, we'd like to make the job a bit easier for you. We only need the last digit of the number of calls, when this number is represented in base b.
The input consists of several test cases. For each test case, you'll be given two integers n (0 ≤ n < 263 – 1) and b (1 < b ≤ 10000). The input is terminated by a test case where n = 0 and b = 0, you must not process this test case.
For each test case, print the test case number first. Then print n, b, and the last digit (in base b) of the number of calls. There should be a single space between two numbers of a line.
Note that the last digit has to be represented in decimal number system.
Output for Sample Input
|University of Debrecen; Faculty of Informatics; v. 03/01/2019|