Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- long factorial(long number){
- long result = 1;
- for (int i = 1; i <= number; ++i){
- result = result * i;
- }
- return result;
- }
- long NewtonBinom(int n, int k){
- long result = factorial(n) / (factorial(k) * factorial(n-k));
- return result;
- }
- int main()
- {
- int n, k;
- cout << "Wpisz liczbe n: " << endl;
- cin >> n;
- cout << "Wpisz liczbe k: " << endl;
- cin >> k;
- if (n < k){
- cout << "Niepoprawne liczby. Liczba n musi być większą równą k";
- }
- else{
- int binom = NewtonBinom(n, k);
- cout << "Symbol newtona dla liczb n = " << n << " oraz k = " << k
- << " równa się " << binom;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement