New course! Every coder should learn Generative AI!
Try a free lesson+ 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 Answers
+ 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 .