-
https://algo.monster/problems/math-basics
-
reverse number
- ans=0
while(digit != 0 ) mod = x%10; digit = digit/10; ans = ans*10+mod
before setting up ans edge condition
if ((ans > (INT_MAX - abs(digit))/10) || (ans < (INT_MIN + abs(digit))/10) ) return 0
-
Armstrong number → 23 = 2³ + 3³ = 35
-
HCF = GCD = biggest number that divides both
- for i =0 → min(a, b) if ( a%i==0 and b%i ==0 ) then update ans
- LCM(a,b) × GCD(a,b) = a×b
- Euclidean Algorithm GCD(a, b) = GCD(b, a % b)
GCD(48, 18) → 48 % 18 = 12 so gcd(18, 12) → 18 % 12 = 6 so gcd(12, 6) → 12 % 6 = 0 so gcd(6, 0) When b=0 → GCD = a always