write a program in java to find the sum of the series 1+4+9+.....n terms
Answers
Answered by
2
import java.util.*;
public class series
{
public static void main(String args[])
{
int n,s=0,i,sq;
System.out.println("Enter a number");
n=sc.nextInt();
for(i=1;i<=n;I++)
sq=Math.pow(i,2);
s=s+sq;
System.out.println("The sum of series is "+s);
}
}
Please mark as brainliest!!!
Similar questions