Problem 56065. Easy Sequences 74: Fibonacci Bank Account
In fantasy world where money does grow on trees, a man decided to top-up his bank account, daily. On the first day he noticed that he has initial "integer" balance of
, so he made his first "integer" deposit of
. On the next days, he made deposit equivalent to the day's starting balance plus the amount he deposited on the previous day. This means that on any k-th day the following formula for the amount he would deposit, holds:
.
Given that on the n-th day, he made a deposit of
, calculate his initial balance
, his first deposit
, and his final ending balance at the end of the n-th day transaction. It is also known that the first deposit he made (
) is the smallest possible first deposit to attain
at the n-th day, using the above formula.
While the account balances can be negative, deposits are always positive (no withdrawals please).
For example, bank statements if
and
, are shown below. His first deposit
, is the smallest possible first deposit to attain a deposit of
on the 5-th day. His starting balance should be
, and his ending balance at 5-th day should be
.
Since this problem involves unbelievable sums of money, please reduce your answer modulo
. Therefore for the above example the final answer should be:
>> k = mod([-30,20,80],2178309)
k =
2178279 20 80
HINT: Use of a big integer arithmetic implementation, is not required in this problem. You can get the modulus using Pisano Period.
is the
-nd Fibonacci number. Also, the ratio of the day's ending balance to the deposit approaches the Golden Ratio as the values of n gets larger.
Solution Stats
Problem Comments
-
1 Comment
GeeTwo
on 15 Dec 2022
Noete that Test 12 not only forbids java, BigInteger, persistent, and global, but also control structures: if, for, switch, while, try.
Also, there's a song in there somewhere:
Fibonacci, number thirty two
♫ ♪ ♩ ♫ ♩ ♫ ♩ ♪ ♩
two one seven eight three oh ni-i-ine
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
2303 Solvers
-
Golomb's self-describing sequence (based on Euler 341)
152 Solvers
-
13897 Solvers
-
Classify product/digit-sum sequences
11 Solvers
-
Easy Sequences 79: Trailing Zeros of Fibonorial Numbers at any Base
3 Solvers
More from this Author116
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!