# 52 Week Challenge [duplicate]

The 52 week challenge is a way to save money. For example, Week 1, you save $1.00. Week 2 you save$2.00, and it continues through the year, adding one more dollar to each week’s savings goal. By Week 52, you’ll set aside $52.00, which will bring the year’s total savings to$1,378! Of course, you can decide how much money you start saving and how many weeks.

Given an amount for Week 1 and the number of weeks the challenge should run for, return the total amount saved at the end of the challenge.

Week 2 will have as twice the amount of Week 1, Week 3 will have thrice the amount of Week 1, etc.

### Examples

1 and 52 weeks: 1378

5 and 6 weeks: 105

.25 and 100 weeks: 1262.5

10 and 1 week: 10

7 and 0 weeks: 0

0 and 30 weeks: 0

0 and 0 weeks: 0

• This challenge is very poorly specified; the task is unclear and it lacks any winning or validity criterion. Please respecify it so the exact task is clear and it is easy to determine if a submission is valid and which submissions win. – HyperNeutrino Dec 21 '17 at 18:54
• Hi, Welcome to PPCG! We generally host programming competitions, and the challenges here should have a clear specification in order to indisputably decide whether an answer is valid and a winning criterion to determine which submission wins. For guidance, you can visit this meta thread: How does this site work? It might be worth reading through this too. For future challenges, we can help you improve them with the Sandbox. :-) – Mr. Xcoder Dec 21 '17 at 20:01
• I've edited your post to conform to our standards while following a possible interpretation of your original text. If it doesn't suit you, feel free to roll the edit back. – Adám Dec 21 '17 at 20:03
• @cairdcoinheringaahing That's $1+$2+$3+…+$52=\$1378. – Adám Dec 21 '17 at 20:50
• I've voted to close this as a duplicate of sum all integers from 1 to n, because it requires simply computing that result and multiplying it by another input. – Post Rock Garf Hunter Dec 21 '17 at 22:34

# Japt, 5 bytes

Takes weeks as the first input and starting amount as the second.

õ x*V


Try it

• Alternatively, õ*V X – ETHproductions Dec 21 '17 at 22:12

# J, 6 bytes

*2!1+]


Takes the amount as the left argument and the weeks as the right argument.

Try it online!

### Explanation

* 2 ! 1 + ]
1 + ]  Add 1 to the weeks.
2 !        (Weeks + 1 choose 2)
*            Multiply by the starting amount.


This takes advantage of the fact that the nth triangle number is (n+1 choose 2). Perhaps unsurprisingly, this is almost the exact same answer as the one I have for the sum of digits from 1 to n challenge. Just substitute >: for 1+] and tack on the *.

# R, 23 bytes

function(a,w)sum(0:w*a)


Try it online!

Takes input as amount, weeks.

# Python 3, 20 bytes

lambda a,w:a*w*-~w/2


Try it online!

# Jelly, 3 bytes

R×S


Try it online!

# Wolfram Language (Mathematica), 13 bytes

#*(#+1)*#2/2&


Try it online!