+ 1

I need program whiCH ables to calculates the factorial of 200 (200!).

I tried below program with unsigned long long but still 200! is more than that so I am getting 0 as output. #include<iostream> using namespace std; int num; int factorial(int n) { if (n==1) { return 1; } else { return n * factorial(n-1); } } int main() { cin >> num; cout << factorial(num); }

7th Dec 2017, 2:22 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
4 Respuestas
+ 3
7th Dec 2017, 3:55 AM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 5
You could use a vector<int> to make your own "BigNum" class. So instead of int=19345 you would have vector <int> {1, 9, 3, 4, 5}. Then you would have to define multiplication for these BigNum objects.
7th Dec 2017, 2:33 AM
Eric Blinkidu
Eric Blinkidu - avatar
+ 4
Wow, you did it! Excellent!
7th Dec 2017, 5:12 AM
Eric Blinkidu
Eric Blinkidu - avatar
7th Dec 2017, 6:16 AM
#RahulVerma
#RahulVerma - avatar