Hey number lovers believe it or not 2015 is a special year. What happens in January may repeat in December !!! Why ??? Because 2015 is 111101111 in binary. Yes, it's a palindrome. In fact 2015 is the last Binary Palindrome Year we’ll Have Until 2047
And this doesn't end here. We have three binary palindrome dates (in ddmmyy) this year. Sad part is we have already missed one of them :(
They are:-
Mon Jan 05 2015, Tue Mar 10 2015
Sun Jun 21 2015
And here's a jsfiddle and js code to prove this :D
function isPalindromeDate(date) {
return Number(date.getDate() + "" + date.getMonth() + "" + date.getYear()).toString(2).split("").reverse().join("") == Number(date.getDate() + "" + date.getMonth() + "" + date.getYear()).toString(2);
}
var date = new Date("01/01/2015");
var i;
for (i = 0; i < 365; i++) {
date.setDate(date.getDate() + 1);
if (isPalindromeDate(date)) {
document.querySelector("body").innerHTML +="Yuureekaa !!!: " + date + " - is a binary palindrome in ddmmyyyy
";
}
}
Feel free to use the above functions to find out if any of you have a binary palindrome birthday. Do let me know if you find one cos I don't have one :( :D
No comments:
Post a Comment