Jump to content

andreis

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by andreis

  1. The Python code returns the smallest palindrome P given an integer p (num in the code).

     

    import sys
    def is_palindrome(num):
    if (num % 10 == 0):
    return False;
    r = 0;
    while (r < num) :
    r = 10 * r + num % 10;
    num /= 10;
    return (num == r) or (num == r / 10);
    num = input("Enter a positive integer:");
    k=0;
    multiple=12;#initialisation: any non-palindrome
    while (not is_palindrome(multiple)):
    k+=1;
    multiple=k*num;
    print(str(num)+"*"+str(k)+"="+str(multiple));


    Hi Function,

     

    Your formula doesn't work for odd numbers. The digit in the middle will have the number (n+1)/2, and you will have a sum member 2*x_i*10^{(n-1)/2} instead of x_i*10^{(n-1)/2}.

     

    I made a similar decomposition, but could not get any conclusion from it.

  2. A palindrome is a number which reads the same backward or forward (e.g. 434, 87678, etc.). Could you prove that for any integer n (not divisible by 10) there is a palindrome (in decimal representation) divisible by n?

    ***

    I've checked for all numbers up to 162, it's true:

    81* 12345679= 999999999

    162*172839506=27999999972

     

    Is there any simple proof for any integer?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.