using System;
public class Demo {
public static long funcReverse(long num) {
long myRev = 0;
while (num > 0) {
myRev <<= 1;
if ((num & 1) == 1)
myRev ^= 1;
num >>= 1;
}
return myRev;
}
public static bool checkPalindrome(long num) {
long myRev = funcReverse(num);
return (num == myRev);
}
public static void Main() {
// Binary value of 5 us 101
long num = 5;
if (checkPalindrome(num))
Console.WriteLine("Palindrome Number");
else
Console.WriteLine("Not a Palindrome Number");
}
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265893.html