SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6.  
  7. int fib(int x) {
  8.     if (x == 0)
  9.         return 0;
  10.  
  11.     if (x == 1)
  12.         return 1;
  13.  
  14.     return fib(x-1)+fib(x-2);
  15. }
  16.  
  17. int dc(int x, int y) {
  18.     if (x == y) return x;
  19.     if (x > y) return dc(x - y, y);
  20.     if (x < y) return dc(x, y -x);
  21. }
  22.  
  23. int suma(int x) {
  24.     if (x == 0) return 0;
  25.     return x % 10 + suma(x / 10);
  26. }
  27.  
  28. int32_t main() {
  29.     int n, a, b;
  30.     cin >> n >> a >> b;
  31.     cout << "Fib(n) = " << fib(n) << endl;
  32.     cout << "GCD(x, y) = " << dc(a, b) << endl;
  33.     cout << "suma(n) = " << suma(n) << endl;
  34.     cout << "suma(x) = " << suma(a) << endl;
  35.     cout << "suma(y) = " << suma(b) << endl;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top