Question
Adam's Charity
Adam decides to be generous and do some charity. Starting today, from day 1
until day n, he gives il coins to charity on day '' (1 <=i<= n).
Return the total coins he would give to charity
Input Specification:
input1: Number of days of charity
Answers
Answered by
1
Answer:
import java.util.*;
class Adam {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
for(int i=1;i<=n;i++)
sum += Math.pow(i,2);
System.out.println(sum);
}
}
Explanation:
Answered by
0
Answer:
Since Adam has decide to do charity and be generous. It will help him to gain the satisfaction.
Explanation:
import java.util.*;
class Adam { public static void main(String[] args)
{ Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
for(int i=1;i<=n;i++)
sum += Math.pow(i,2);
System.out.println(sum);}
Similar questions
Math,
2 months ago
Chemistry,
2 months ago
English,
2 months ago
Social Sciences,
6 months ago
Math,
6 months ago
Accountancy,
10 months ago
Physics,
10 months ago