3
$\begingroup$

Determine all possible positive palindrome(s) N numbers, such that the decimal representation of 2 x N^2 has no leading zeroes and contains each of the digits from 0 to 9 exactly once.

$\endgroup$

closed as off-topic by Peter Taylor, JMP, Hugh Meyers, boboquack, Oray Sep 20 '17 at 7:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is off-topic as it appears to be a mathematics problem, as opposed to a mathematical puzzle. For more info, see "Are math-textbook-style problems on topic?" on meta." – Peter Taylor, JMP, Hugh Meyers, boboquack, Oray
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ language? $\endgroup$ – boboquack Sep 20 '17 at 6:23
  • $\begingroup$ @boboquack Sorry i was understood programming language. $\endgroup$ – Smart Sep 20 '17 at 6:31
  • $\begingroup$ wait....is it $(2 \times N)^2$ or $2 \times N^2$ ? yeah yeah, I know the order of operations. I just want to make sure $\endgroup$ – Marius Sep 20 '17 at 7:09
  • 1
    $\begingroup$ @Marius 2 x N^2 $\endgroup$ – Smart Sep 20 '17 at 7:12
5
$\begingroup$

I think they are:

$N = 46464$ and $2 \times N^2= 4317806592$
$N = 69696$ and $2 \times N^2= 9715064832$

Explanation.

The value of $2*N^2$ should be between 1023456789 and 9876543210.
This means that N has to be between $\sqrt{\frac{1023456789}{2}} = 22621.41$ and $\sqrt{\frac{9876543210}{2}} =70272.83$. Since N is integer it means it has to be between 22622 and 70272.
Wrote a little script that loops through all the numbers and checks if the number is a palindrome and that $2*N^2$ contains all the digits.
Here is my code. It can be tested on http://phpfiddle.org/

<?php

function isPalindrome($string)
{
    return $string == strrev($string);
}

function hasAllDigits($string) {
    $string = (string)$string;
    if (strlen($string) != 10) {
        return false;
    }
    $digits = [];
    for ($i = 0; $i<strlen($string);$i++) {
        if (isset($digits[$string[$i]])) {
            return false;
        }
        $digits[$string[$i]] = 1;
    }
    return true;
}

for ($i = 22622; $i<=70272; $i++) {
    if (!isPalindrome($i)) {
        continue;
    }
    $x = 2*$i*$i;
    if (!hasAllDigits($x)) {
        continue;
    }
    echo $i .'--'.$x.'<br />';
}
$\endgroup$
  • 3
    $\begingroup$ What about 46464 and 69696? 2*n^2 seems to return 4317806592 and 9715064832 for me. $\endgroup$ – numbermaniac Sep 20 '17 at 7:13
  • $\begingroup$ @numbermaniac. Thanks for the heads up. In my defense, I said it's too early and I may have made a mistake in my "software". $\endgroup$ – Marius Sep 20 '17 at 7:14
  • 2
    $\begingroup$ @numbermaniac. Thanks. You are right. I forgot a cast to string. $\endgroup$ – Marius Sep 20 '17 at 7:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.