Computer Science, asked by pavani8011, 1 year ago

write a java program to print 1!+2!+3!+4!....​

Answers

Answered by Anonymous
1

Answer:

public static void main(String args[]) {

double s=0;

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

s=s+(double)i/(double)(i+1);

}

System.out.printf("%.2f",s); //”.2f” for upto 2 decimal places

}

}

output-

3.55 (for 2 decimal place)

3.5500000000000003 (using System.out.print you will get output like this)

Similar questions