Write a program to print the given series upto first n digits Test Case 1 Input (stdin) 5 Expected Output 1 1 2 6 24 Test Case 2 Input (stdin) 7 Expected Output 1 1 2 6 24 120 720
#include <iostream> using namespace std; int main() { int n,i,j=1,pro=1; cin>>n; cout<<"1 "; for(i=1;i<n;i++) { pro=pro*j; cout<<pro<<" "; j++; } return 0; }