Computer Science, asked by musicbag05, 9 months ago

can anyone solve this java series.
1^2-3^2+5^2-7^2+9^2-11^2+13^2...n terms​

Answers

Answered by shardul1925
1

public class Program {

public static void display(int n) {

int a=1;

double s=0.0;

for(int i=1;i<=n;i++) {

s=s - Math.pow(a,2);

a=a+2;

}

System.out.println("Sum="+ s);

}

}

Similar questions