Accenture Coding Question | Adam’s Charity | CodeWindow

Adam’s Charity

Adam decides to be generous and do some charity. starting today, from day 1 until day n, he gives i^2 coins to charity on day ‘i’ (1<=i<=n).
return the total coins he would give to charity.

Input specification:
Input 1: number of days of Charity.

Output Specification:
Return the total number of coins till charity days.

Example 1:
Input 1: 2

Output: 5
Explanation:
There are 2 days.

Example 2:
Input 1: 3

Output: 14
Explanation:
There are 3 days.

Solution in Python 3:

Solution in C++ :

Solution in C :

Solution in JAVA :

Output:

Recent Posts
Pages