Advertisement
Pafnytiu

структуры 2 - 11

Dec 22nd, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. unsigned long F(short n, int x)
  4. {
  5. if (n == -x)
  6. return 1;
  7. else
  8. {
  9. unsigned long n1 = 1, n2 = 2;
  10. for (short i = 3; i <= n; i++)
  11. {
  12. n = (n - 1) + 1;
  13. n1 = n2;
  14. n2 = n;
  15. }
  16. return n;
  17. }
  18. }
  19. unsigned long F_REC(short n, int x)
  20. {
  21. if (n == -x)
  22. return 1;
  23. else
  24. {
  25. return F_REC(x / (n + x));
  26. }
  27. }
  28. int main()
  29. {
  30. short n;
  31. int x;
  32. cout << "n= "; cin >> n;
  33. cout << "x= "; cin >> x;
  34. cout << "F_REC(" << n << ")= " << F_REC(n,x) << endl;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement