wap in java to input n and find the sum of 1 + (1/2)^2 + (1/3)^2 + (1/n)^2.
all inputs using scanner class.
Answers
Answered by
1
Answer:
import java.util.Scanner;
public class Sum
{
public static void main(String arts[])
{
double sum;
Scanner in = new Scanner(System.in);
System.out.println("Enter the value of n");
int n = in.nextInt();
sum=1+((1/2)*(1/2))+((1/3)*(1/3))+((1/n)*(1/n));
System.out.println("Solution of Expression :"+sum);
}
}
Hope this helps you.
PLEASE MARK IT AS THE BRANLIEST !!!
Similar questions
Math,
5 months ago
English,
5 months ago
Social Sciences,
5 months ago
English,
10 months ago
Social Sciences,
1 year ago
India Languages,
1 year ago