Coddy Users - Easy
Lesson 1 of 3 in Coddy's Interview Coding Challenges - Pack III course.
Each week, Coddy has more users than the previous week. The recursion function that represents Coddy's weekly users goes like this:
If previous week had x users, and this week had y users, Coddy is going to have x + 3y users in the next week.
Coddy had 0 users in the first week and 1 user in the second week.
Challenge
EasyWrite a function getUsers which gets an integer n and returns the amount of users Coddy has in the n'th week.
Example 1,
Input: 3
Expected output: 3
Explanation: in the third week, Coddy will have the amount of users it had in the first week plus twice the amount of users it had in the second week, summing up to 1*0+3*1=3.
Example 2,
Input: 4
Expected output: 10
Example 3,
Input: 5
Expected output: 33
Constraints:
1 < n < 20
Try it yourself
int getUsers(int n) {
// Write code here
}