#include <bits/stdc++.h> using namespace std ; int main (){ int num{0}; while (num != 42){ cin >> num ; if (num != 42){ cout << num << '\n'; } } return 0 ; }
#include <bits/stdc++.h> using namespace std ; int fact ( int n){ //1st step Base Case if (n== 0 ){ return 1 ; } int smallans = fact(n- 1 ) ; // 2nd step Assumption Recursive Case int ans = n*smallans ; //3rd step Calculation return ans ; } int main (){ int n ; cin >> n ; cout << fact(n) << ' \n ' ; return 0 ; }
Comments
Post a Comment