Codes/Volume 01/E0036 Double-base palindromes.cpp
/*
Statement:
 The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.

 Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

 (Please note that the palindromic number, in either base, may not include leading zeros.)
*/
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.

Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

(Please note that the palindromic number, in either base, may not include leading zeros.)
The decimal number 585 = 10010010012 ( binary ) is palindromic in both bases . Find the sum of all numbers less than one million which are palindromic in base 10 and base 2 . ( Please note that the palindromic number in either base may not include leading zeros . )
ll nthEvenOddPalindrome(ll num, bool oddlength, ll base = 10){
    ll ret = num;
    if(oddlength) num /= base;
    while(num){
        ret *= base;
        ret += num % base;
        num /= base;
    }
    return ret;
}
ll nthEvenOddPalindrome ( ll num , bool oddlength , ll base = 10 ) { ll ret = num ; if ( oddlength ) num /= base ; while ( num ) { ret *= base ; ret += num % base ; num /= base ; } return ret ; }
Statement:
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Statement : The decimal number 585 = 10010010012 ( binary ) is palindromic in both bases .