Guest User

Untitled

a guest
Jan 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll long long
  5.  
  6. int gcd_sum(int n)
  7. {
  8. ll sum = 0;
  9. for(int i = 1; i <= n; i++)
  10. sum += __gcd(i,n); // built in function to calculate GCD
  11. return sum;
  12. }
  13.  
  14. int main()
  15. {
  16. ll n;
  17. cin >> n;
  18. cout << gcd_sum(n) << endl;
  19.  
  20. return 0;
  21. }
Add Comment
Please, Sign In to add comment