Advertisement
V-blk

Untitled

Jan 17th, 2025
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.28 KB | None | 0 0
  1. public bool IsPalindrome(int x) {
  2.         if(x < 0) return false;
  3.  
  4.         var t = x;
  5.         var n = 0;
  6.         while(x > 0 )
  7.         {
  8.            
  9.             var mod = x % 10;
  10.             x = x / 10;
  11.             n = n * 10 + mod;
  12.         }
  13.  
  14.         return t == n;
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement