← Back to challenges

Free Coffee Cups

JavaScriptHardmathlogicnumbersalgorithms

Instructions

For each of the 6 coffee cups I buy, I get a 7th cup free. In total, I get 7 cups. Create a function that takes n cups bought and return as an integer the total number of cups I would get.

Examples

totalCups(6) ➞ 7

totalCups(12) ➞ 14

totalCups(213) ➞ 248

Notes

  • Number of cups I bought + number of cups I got for free.
  • Only valid inputs will be given.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Halloween Day