Skip to content

Commit

Permalink
Merge pull request #34 from dipak-01/contribution
Browse files Browse the repository at this point in the history
Contribution
  • Loading branch information
HarshwardhanPatil07 authored Oct 12, 2023
2 parents 248720f + 758ef27 commit dcdf939
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
| Moh Faizan | <a href="https://github.com/faizanusmani06"> Moh Faizan</a>|
| Praneesh Sharma | <a href="https://github.com/Praneesh-Sharma"> Praneesh Sharma </a>|
| Naman Bagdiya | <a href="https://github.com/NamanOG"> NamanOG </a>|
| Diapk Kurkute| <a href="https://github.com/dipak-01"> dipak-01 </a>|
44 changes: 44 additions & 0 deletions c++/Factorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <iostream>
using namespace std;

class Factorial
{
private:
int num;
unsigned long long factorial = 1;

public:
void calculateFactorial();
void show();
};

void Factorial::calculateFactorial()
{
cout << "Enter a number:" << endl;
cin >> num;

if (num == 0 || num == 1)
{
factorial = 1;
}
else
{
while (num > 1)
{
factorial = factorial * num;
num--;
}
}
}

void Factorial::show()
{
cout << "Factorial: " << factorial << endl;
}

int main()
{
Factorial factorial;
factorial.calculateFactorial();
factorial.show();
}

0 comments on commit dcdf939

Please sign in to comment.