nCr calculator in C
29
c/calculators/ncr.c
Normal 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);
|
||||
}
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 799 KiB After Width: | Height: | Size: 799 KiB |
Before Width: | Height: | Size: 827 KiB After Width: | Height: | Size: 827 KiB |
Before Width: | Height: | Size: 834 KiB After Width: | Height: | Size: 834 KiB |
Before Width: | Height: | Size: 832 KiB After Width: | Height: | Size: 832 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
Before Width: | Height: | Size: 1 MiB After Width: | Height: | Size: 1 MiB |
Before Width: | Height: | Size: 543 KiB After Width: | Height: | Size: 543 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 1 MiB After Width: | Height: | Size: 1 MiB |
Before Width: | Height: | Size: 161 KiB After Width: | Height: | Size: 161 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 474 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 207 KiB |