nCr calculator in C

This commit is contained in:
newtykins 2021-12-21 19:46:28 +00:00
parent d880215d09
commit c20f5e2cdb
142 changed files with 52 additions and 20 deletions

29
c/calculators/ncr.c Normal file
View file

@ -0,0 +1,29 @@
#include <stdio.h>
int factorial(int n) {
int ans = 1;
for (int i = 2; i <= n; i++) {
ans *= i;
}
return ans;
}
int nCr(int n, int r) {
return factorial(n) / factorial(r) * factorial(n - r);
}
void main() {
int n;
int r;
printf("Please enter n: ");
scanf("%i", &n);
printf("Please enter r: ");
scanf("%i", &r);
int ans = nCr(n, r);
printf("The answer is: %i", ans);
}

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View file

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -5,12 +5,12 @@
### Data Science ### Data Science
- [Fake Jobs Scraper](data%20science/Fake%20Jobs.py) - [Fake Jobs Scraper](data-science/Fake%20Jobs.py)
- [Country Population vs Active Facebook Users in the Country](data%20science/Facebook.py) - [Country Population vs Active Facebook Users in the Country](data-science/Facebook.py)
- [Estimated Revenue for the top Twitch channels](data%20science/Twitch%20Revenue.py) - [Estimated Revenue for the top Twitch channels](data-science/Twitch%20Revenue.py)
- [ngrams](data%20science/ngrams) - [ngrams](data-science/ngrams)
- [Comparison](data%20science/ngrams/comparison/Comparison.py) - [Comparison](data-science/ngrams/comparison/Comparison.py)
- [Popularity](data%20science/ngrams/popularity/Popularity.py) - [Popularity](data-science/ngrams/popularity/Popularity.py)
### Calculators ### Calculators
@ -25,6 +25,6 @@
### Other ### Other
- [PP Calculator](pp.py) - [PP Calculator](pp.py)
- [2 Stars List](geometry%20dash%202%20stars/script.py) - [2 Stars List](gd-two-star-list)
- [Pong (made with Pygame)](pong) - [Pong (made with Pygame)](pong)
- [pythonchallenge.com](pythonchallenge.com) - [pythonchallenge.com](pythonchallenge.com)

View file

@ -8,5 +8,8 @@
### Table of contents ### Table of contents
- [Python](python) - [Python](python)
- [GCSE Computer Science](gcse%20computer%20science) - [C](c)
- [Royal Institute Computer Science Masterclass 2021](royal%20institute%20computer%20science%20masterclass%202021) - [Project Euler](euler)
- [GCSE Computer Science](school/gcse)
- [Royal Institute Computer Science Masterclass 2021](school/royal%20institute)
- [r/dailyprogrammer](daily-programmer)

View file

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 333 B

View file

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View file

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

Before

Width:  |  Height:  |  Size: 799 KiB

After

Width:  |  Height:  |  Size: 799 KiB

View file

Before

Width:  |  Height:  |  Size: 827 KiB

After

Width:  |  Height:  |  Size: 827 KiB

View file

Before

Width:  |  Height:  |  Size: 834 KiB

After

Width:  |  Height:  |  Size: 834 KiB

View file

Before

Width:  |  Height:  |  Size: 832 KiB

After

Width:  |  Height:  |  Size: 832 KiB

View file

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View file

Before

Width:  |  Height:  |  Size: 1 MiB

After

Width:  |  Height:  |  Size: 1 MiB

View file

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View file

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

View file

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

View file

Before

Width:  |  Height:  |  Size: 1 MiB

After

Width:  |  Height:  |  Size: 1 MiB

View file

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 161 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View file

Before

Width:  |  Height:  |  Size: 474 KiB

After

Width:  |  Height:  |  Size: 474 KiB

View file

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 77 KiB

View file

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View file

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Some files were not shown because too many files have changed in this diff Show more