write a java program to print 1!+2!+3!+4!....
Answers
Answered by
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
Math,
6 months ago
Geography,
6 months ago
Accountancy,
6 months ago
English,
1 year ago
Hindi,
1 year ago