forked from natto1784/ooplab
24
lab3/7.cpp
Normal file
24
lab3/7.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
uint64_t factorial(uint n) { return (n ? n * factorial(n - 1) : 1); }
|
||||
|
||||
class NumberWithFactorial {
|
||||
private:
|
||||
uint n;
|
||||
uint64_t f;
|
||||
|
||||
public:
|
||||
NumberWithFactorial(uint);
|
||||
};
|
||||
|
||||
NumberWithFactorial::NumberWithFactorial(uint n) {
|
||||
this->n = n;
|
||||
this->f = factorial(n);
|
||||
cout << "Factorial of " << this->n << " is " << this->f << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
NumberWithFactorial(5);
|
||||
}
|
Reference in New Issue
Block a user