Live data from Hacker News

Any positive number can be written as a sum of three palindromes

somethingorotherwhatever.com

61–70 of 114 posts

Re: Any positive number can be written as a sum of three palindromes

#61

i'm underwhelmed 77777777777777 +0 +0 =77777777777777

yeah....I don't see why this such an "impressive" trick.

OK tough guy, please give me three palindromic numbers that add up to 1,234,567. And don't use the trick! And don't use brute force!

Re: Any positive number can be written as a sum of three palindromes

#62
post #6
post #4

Every positive number is a sum of infinite palindromes since they include 0 as a palindrome. Try entering 101.

It's easier to find more than fewer palindromes that when summed up will give a certain number. Finding just the three, is not that easy.

And just to clarify, the greedy algorithm (take the largest palindrome less than the number you're trying to express) doesn't work. To take a random nine-digit example (literally the first one I tried): 635932028 = 635929536 + 2442 + 44 + 6. In general you can express N as a sum of something like log(log(N)) palindromes this way, which is not quite constant.

Re: Any positive number can be written as a sum of three palindromes

#63
post #51

It seems to go for the "least interesting" result. eg: I gave it 363 and it gave me back 363 + 0 + 0, which while technically true, 121 + 121 + 121 would have been more in the spirit of it, IMO. Or even 242 + 121 + 0 would be a little easier than just reusing the original palindrome number with zeros.

Well it proofs the existence and there are many special cases they consider. If the number is a palindrome already there are many possible solutions. Using zeros is a trivial an the simplest solution. Using anything else would be abitrary and longer too.

Re: Any positive number can be written as a sum of three palindromes

#64

Earlier quoted context omitted.

I got 10,067,892,461 = 9,910,110,199 + 144,959,441 + 12,822,821, which I think is pretty impressive.

Ah that is neat. For most smaller numbers, it seems to use 0 a lot, which is not interesting. But your example is the first one I saw that didn't include 0.

It uses 0 a lot because you're giving it such easy numbers that it only needs to solve them as the sum of two palindromes.

Re: Any positive number can be written as a sum of three palindromes

#65
post #61

Earlier quoted context omitted.

yeah....I don't see why this such an "impressive" trick.

OK tough guy, please give me three palindromic numbers that add up to 1,234,567. And don't use the trick! And don't use brute force!

1234321 + 242 + 4

Re: Any positive number can be written as a sum of three palindromes

#66
post #59

For those wondering, this works in every base ≥ 5, according to the original paper: https://arxiv.org/abs/1602.06208v2 Every time I see something like this that is dependent on base-10 representation, I'm always curious to know whether it generalizes, or if it's a quirk specific to base-10 representation. For example, being able to tell if a number is divisible by 2 or 5 by only looking at the last digit.

> For example, being able to tell if a number is divisible by 2 or 5 by only looking at the last digit. That still seems like it is generalizable to any base by taking prime factors of any base-n.

It is, but there's nothing special about 2 or 5 except that they're factors of 10.

Re: Any positive number can be written as a sum of three palindromes

#67

For those wondering, this works in every base ≥ 5, according to the original paper: https://arxiv.org/abs/1602.06208v2 Every time I see something like this that is dependent on base-10 representation, I'm always curious to know whether it generalizes, or if it's a quirk specific to base-10 representation. For example, being able to tell if a number is divisible by 2 or 5 by only looking at the last digit.

And according to the Numberphile video ( https://www.youtube.com/watch?v=OKhacWQ2fCs ) there is a prior paper showing it for bases 2, 3, and 4

Oh nice, so it works in every base then. Awesome.

Re: Any positive number can be written as a sum of three palindromes

#68

Could this trick be used to improve compression? Since palindromes contain repeated digits by definition, perhaps they are more compressible than the original number? Of course, you'd have three numbers to compress instead of one...

Palindrome detection in general is a rather interesting consideration to keep in mind...

Re: Any positive number can be written as a sum of three palindromes

#69
post #9

Wonderful wonderful website. What happends to quirky people like this when they leave university and enter the industry?

yup, super fun. Would be even more awesome if there was explanation of the process as the numbers are being found, might be more accessible than reading the paper.

I wish there was a list of sites like these - learning for the pure joy of learning, with no other expectations.

Post reply on HN