Computer Science, asked by sonyrajput923, 6 months ago

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 harshaa1703
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 varsha955769
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