I was working on this basic problem:
Factorials - Problem 1, C++ programming challenge, Java programming challenge
I have the right answer but in the wrong format.Code:public class Factorials { // n! public static long factorial( int n ) { if( n <= 1 ) return 1; else return n * factorial(n-1); } public static void main(String [ ] args) { double temp = 0.0; double ans = 0.0; for( int i = 1; i <= 15; i++ ){ temp = factorial( i ); ans = (ans + temp); } System.out.println( ans ); } }
1.401602636313E12
How would i convert it to a decimal form?


LinkBack URL
About LinkBacks