← Back to challenges

Doubled Pay

JavaScriptHardmathloopsnumbers

Instructions

An employee working at a very bizarre company earns one penny on their first day. However, for every day that passes, their base amount doubles, so they earn two pennies on the second day and four pennies on the third day (totalling 7 pennies). Given a number of days, return how many pennies the employee accumulates.

Examples

doubledPay(1) ➞ 1

doubledPay(2) ➞ 3

doubledPay(3) ➞ 7

Notes

You will only get tests for valid positive integers.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: An Absolute