+ 1
Java program
Write a program to find the sum of the following series: (1â 1)+(2â 2)+(3â 3)+(4â4)+...+(nâ n) Output: User input: 6 1â 1=1 2â 2=4 3â 3=9 4â 4=16 5â 5=25 6â 6=36 The summation of the series: 91
4 Respostas
+ 10
ۧÙ
ÙŰ±Ù Ű§ÙÙ۱ÙÙ
to get useful help from the community, we need to see your attempt first. without having seen your code, it is difficult to find out where the issue is.
=> please put your code in playground and link it here
thanks!
+ 6
ۧÙ
ÙŰ±Ù Ű§ÙÙ۱ÙÙ
Hint -
1 - Use for loop and start iteration from 1 to userinput
2 - get square of each iteration value
3 - get sum of each square value.
+ 1
class Series
{
public static void main(String args)
{
int n = Integer.parseInt(args[0]);
int s=0;
for(int i=1;i<=n;i++)
{
System.out.println(i + â * â + i + â = â + i*i);
s+= (i*i);
}
System.out.println(âThe summation of the series : â + s);
}
}
0
ۧÙ
ÙŰ±Ù Ű§ÙÙ۱ÙÙ
if you want me to explain how to solve this in Arabic ; I am ready .