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,26 +5,26 @@
### Data Science
- [Fake Jobs Scraper](data%20science/Fake%20Jobs.py)
- [Country Population vs Active Facebook Users in the Country](data%20science/Facebook.py)
- [Estimated Revenue for the top Twitch channels](data%20science/Twitch%20Revenue.py)
- [ngrams](data%20science/ngrams)
- [Comparison](data%20science/ngrams/comparison/Comparison.py)
- [Popularity](data%20science/ngrams/popularity/Popularity.py)
- [Fake Jobs Scraper](data-science/Fake%20Jobs.py)
- [Country Population vs Active Facebook Users in the Country](data-science/Facebook.py)
- [Estimated Revenue for the top Twitch channels](data-science/Twitch%20Revenue.py)
- [ngrams](data-science/ngrams)
- [Comparison](data-science/ngrams/comparison/Comparison.py)
- [Popularity](data-science/ngrams/popularity/Popularity.py)
### Calculators
- [Binomial Distribution](calculators/Binomial%20Distribution.py)
- [Karatsuba Algorithm](calculators/Karatsuba%20Algorithm.py)
- [Pearson's Product-Moment Correlation Coefficient](calculators/PMCC.py)
- [Quadratic nth Term](calculators/Quadratic%20nth%20Term.py)
- [Square Root](calculators/SQRT.py)
- [Spearman's Rank Correlation Coefficient](calculators/SRCC.py)
- [Standard Deviation](calculators/STDEV.py)
- [Binomial Distribution](calculators/Binomial%20Distribution.py)
- [Karatsuba Algorithm](calculators/Karatsuba%20Algorithm.py)
- [Pearson's Product-Moment Correlation Coefficient](calculators/PMCC.py)
- [Quadratic nth Term](calculators/Quadratic%20nth%20Term.py)
- [Square Root](calculators/SQRT.py)
- [Spearman's Rank Correlation Coefficient](calculators/SRCC.py)
- [Standard Deviation](calculators/STDEV.py)
### Other
- [PP Calculator](pp.py)
- [2 Stars List](geometry%20dash%202%20stars/script.py)
- [Pong (made with Pygame)](pong)
- [pythonchallenge.com](pythonchallenge.com)
- [PP Calculator](pp.py)
- [2 Stars List](gd-two-star-list)
- [Pong (made with Pygame)](pong)
- [pythonchallenge.com](pythonchallenge.com)

View file

@ -7,6 +7,9 @@
### Table of contents
- [Python](python)
- [GCSE Computer Science](gcse%20computer%20science)
- [Royal Institute Computer Science Masterclass 2021](royal%20institute%20computer%20science%20masterclass%202021)
- [Python](python)
- [C](c)
- [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