Created
July 29, 2022 11:31
-
-
Save outlinepix/3f56299879b89cc686c0fa69ef1044a2 to your computer and use it in GitHub Desktop.
Find the nth Reverse Number (Extreme) in C language
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned long long int find_reverse_number(unsigned long long int nth) { | |
unsigned long long int result = 0, count = 0; | |
for ( unsigned long long int i = 0; i <= 10000000000; i++) | |
{ | |
unsigned long long int reversed = 0, remainder; | |
unsigned long long int n = i; | |
while (n != 0) | |
{ | |
remainder = n % 10; | |
reversed = reversed * 10 + remainder; | |
n /= 10; | |
} | |
if (reversed == i) | |
{ | |
count++; | |
if (count == nth){ | |
result = i; | |
break; | |
} | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment