CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <thread>
#include <mutex>
using namespace std;
recursive_mutex rm;
mutex m;
int intResult = 1;
void getFatctorial(int intNum)
{
if (intNum <=1)
{
cout << intResult << endl;
}
else
{
m.lock();
intResult *= intNum;
m.unlock();
getFatctorial(intNum-1);
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run