Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- double power(double x, int n)
- {
- if (n == 0)
- return 1;
- else
- {
- if (n < 0)
- {
- n = abs(n);
- x = 1.0 / x;
- }
- return x*power(x,n-1);
- }
- }
- int binom(int m, int n)
- {
- if (m == n || m == 0)
- return 1;
- else
- return binom(m , n-1) + binom(m - 1, n - 1);
- }
- int main()
- {
- double x=0.5;
- int n =-3;
- //cout << power(x, n) << endl;
- cout << binom(3,5) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment