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
-
7338 Solvers
-
Project Euler: Problem 5, Smallest multiple
1489 Solvers
-
Back to basics - mean of corner elements of a matrix
418 Solvers
-
50 Solvers
-
1625 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!