Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save outlinepix/3f56299879b89cc686c0fa69ef1044a2 to your computer and use it in GitHub Desktop.
Save outlinepix/3f56299879b89cc686c0fa69ef1044a2 to your computer and use it in GitHub Desktop.
Find the nth Reverse Number (Extreme) in C language
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