| 44 | } |
| 45 | |
| 46 | void solve(){ |
| 47 | // solution starts from here |
| 48 | int n, i; |
| 49 | cin>>n; |
| 50 | |
| 51 | |
| 52 | if ( vec_2d[n][0] != 0 ){ //Print factorial, if its already calculated |
| 53 | print_fact(n); |
| 54 | } |
| 55 | else{ |
| 56 | for (i=n-1; i>=1; i--) // Check for calculated factorial of immediate prev num (less than num) |
| 57 | if (vec_2d[i][0] != 0) |
| 58 | break; |
| 59 | |
| 60 | for (int k=i+1; k<=n; k++){ // Calculate factorial from the point, its not present till n |
| 61 | calc_fact(k); |
| 62 | } |
| 63 | print_fact(n); // Print the factorial of n |
| 64 | } |
| 65 | |
| 66 | } |
| 67 | |
| 68 | int main(){ |
| 69 | int tt; |
no test coverage detected