note: in instantiation of function template specialization 'std::__1::__gcd' requested here while (__gcd(n, k) <= 1) n++;
The above line was displayed along with the error shown earlier, I know there are many other methods to calculate gcd but I am confused why it's not working for (__gcd() ).
I am using MacBook : OS -> BgSur
Apple clang version 12.0.0 (clang-1200.0.32.29)
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int getSum(int n)
{
int sum;
for (sum = 0; n > 0; sum += n % 10, n /= 10)
;
return sum;
}
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
int k = getSum(n);
while (__gcd(n, k) <= 1) n++;
cout << n << endl;
}
}
here, getSum(125) = 1+2+5 = 8
INPUT :
3
11
31
75
OUTPUT:
12
32
75
EXPECTED OUTPUT:
12
33
75