You're right....also using a switch statement as you did saves us space, instead of storing vowels in a data structure. Although the space used for the small amount of data we are storing is essentially negligiable.
Per the Kata's definition of capital, "We will consider a, e, i, o, and u as vowels for this Kata," there are no capital vowels. You could always lowercase the string first if you like, though.
The description is quite poorly worded. This might be an improvement:
A geometric sequence is one in which the (i+1)th term is found by multiplying the (i)th term by a fixed non-zero number, r.
For example, for r = 3:
s = 2, 6, 18, 54, ...
is a geometric sequence.
Your task is to write a function geometric_sequence_sum(a, r, n) that will return the SUM of the first n elements of a geometric sequence with the given constant r and first element a.
For example: geometric_sequence_sum(2, 3, 5) should return: 242 = 2 + 6 + 18 + 54 + 162
Damn...
Test suite now covers this and other edge cases.
Fixed.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
nice dude.
This comment is hidden because it contains spoiler information about the solution
This should be fixed.
You're right....also using a switch statement as you did saves us space, instead of storing vowels in a data structure. Although the space used for the small amount of data we are storing is essentially negligiable.
Per the Kata's definition of capital, "We will consider a, e, i, o, and u as vowels for this Kata," there are no capital vowels. You could always lowercase the string first if you like, though.
Fails for Capital vowels
This comment is hidden because it contains spoiler information about the solution
Can't upvote that enough. Thanks jmeek
This comment is hidden because it contains spoiler information about the solution
The description is quite poorly worded. This might be an improvement:
A geometric sequence is one in which the (i+1)th term is found by multiplying the (i)th term by a fixed non-zero number, r.
For example, for r = 3:
s = 2, 6, 18, 54, ...
is a geometric sequence.
Your task is to write a function geometric_sequence_sum(a, r, n) that will return the SUM of the first n elements of a geometric sequence with the given constant r and first element a.
For example: geometric_sequence_sum(2, 3, 5) should return: 242 = 2 + 6 + 18 + 54 + 162
Loading more items...