Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<locale>
- using namespace std;
- int RecursivePow(int base, int power)
- {
- long long int pow=1;
- if (power==0)
- return pow;
- else
- return pow=pow*base*RecursivePow(base,power-1);
- }
- int Recursive(int base)
- {
- long long int fact=1;;
- if (base==0)
- fact=1;
- else
- fact=fact*base*Recursive(base-1);
- return fact;
- }
- int main()
- {
- setlocale(LC_ALL,"rus");
- int n;
- cout<<"Введите число"<<endl;
- while((!(cin >>n))||(n<0))
- {
- cout << "Вы ввели некорректные данные, попробуйте еще раз\n";
- cin.clear();
- cin.sync();
- }
- cout<<"a"<<n<<"="<< double(RecursivePow(3,n))/ double(Recursive(n))<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement