All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Explicitly Stated (Posted on 2004-08-18)
A certain bank doesn't believe in interest and gives none the whole year. However, they do two things as a gift at the end of the year. They put money into your account such that it has 5 times as much as it did before. Then, they put 8 dollars in the account after that.

Jack gets one of these accounts at the start of year 1, and puts in 6 dollars. Assuming there are no other withdrawals or deposits into that account, figure out how much money is in that account at the beginning of year x, even if you don't know how much was in the account any of the previous years.

For example, on the beginning of year 1, he would have 6 dollars. On the beginning of year 2, he would have 38 dollars, and on the beginning of year 3 he would have 198 dollars.

What if you put in A dollars to start at the beginning of the first year, the bank put money into your account at the end of the year such that it was B times as much as before, and then put in C more dollars after that; how much money would you have at the beginning of year x, assuming everything else is normal and there are no withdrawals or deposits, even if you don't know how much was in the account any of the previous years?

 No Solution Yet Submitted by Gamer Rating: 4.0000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Solution | Comment 3 of 11 |
Formula for sum of money in account at beginning of year x is:

For year 1, sum = A
For x>1, sum = (B^[x-1])*A + C*(B^0 + B^1 + B^2 + ..... + B^[x-2])

The following program verifies the formula.

Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
Sub Main()
Randomize()
Dim strgoagain As String
strgoagain = "y"
While strgoagain = "y"
mainline()
Console.WriteLine("Again ? (y/n)")
End While
End Sub

Sub mainline()
Dim dbla As Double
Dim dbla2 As Double
Dim dblb As Double
Dim dblc As Double
Dim intyears As Integer
Dim dblaccum As Double
Dim dblformula As Double
dbla = 0
While dbla <= 0
Console.WriteLine("What is the beginning sum ?")
End While
dbla2 = dbla
dblb = 0
While dblb <= 0
Console.WriteLine("What is the multiplication factor?")
End While
dblc = 0
While dblc <= 0
Console.WriteLine("What is the year-end bonus?")
End While
intyears = 0
While intyears <= 0
Console.WriteLine("How many years should I verify?")
End While
For index1 As Integer = 1 To intyears
computebyaccum(index1, dbla, dblb, dblc, dblaccum)
computebyformula(index1, dbla2, dblb, dblc, dblformula)
Console.WriteLine("After year " & Str(index1) & ":")
Console.WriteLine("By accumulation: " & Str(dblaccum))
Console.WriteLine("By formula: " & Str(dblformula))
Next
End Sub

Sub computebyaccum(ByRef intyear, ByRef dbla, ByRef dblb, _
ByRef dblc, ByRef dblaccum)
If intyear = 1 Then
dblaccum = dbla
Else
dblaccum = _
(dblb * dbla) + dblc
dbla = dblaccum
End If
End Sub

Sub computebyformula(ByRef intyear, ByRef dbla2, ByRef dblb, _
ByRef dblc, ByRef dblformula)
Dim dblwork As Double
If intyear = 1 Then
dblformula = dbla2
Else
dblformula = (dblb ^ (intyear - 1)) * dbla2
dblwork = 0
For index1 As Integer = 0 To intyear - 2
dblwork += dblb ^ index1
Next
dblwork *= dblc
dblformula += dblwork
End If
End Sub
End Module

Edited on August 18, 2004, 11:51 am
 Posted by Penny on 2004-08-18 11:03:43

 Search: Search body:
Forums (0)