Skip to content

Commit

Permalink
Create palindrome-num.c
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedonnan authored Mar 23, 2023
1 parent 56ab32a commit faddc6b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions palindrome-num.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bool isPalindrome(int x){
if (x < 10 && x > -1) {
return true;
}
if (x < 0) {
return false;
}

int temp = x;
long final = 0;

while (temp > 0) {
final *= 10;
final += temp % 10;
temp /= 10;
}
return final == x;
}

0 comments on commit faddc6b

Please sign in to comment.