labs 1-6: init

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2022-12-24 14:03:08 +05:30
commit ad185c994e
26 changed files with 2250 additions and 0 deletions

24
lab3/7.cpp Normal file
View 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);
}