10
Goal:
Given any non-zero natural number a
, find the smallest non-zero natural
number b
such that a•b
is palindromic, e.g. it reads the same forwards and backwards. Input a
through any reasonable means (STDIN, function argument, etc.), And output b
through any reasonable means (STDOUT, function return value.)
Notes:
Input will not always have a solution (multiples of 10), so you must create an error, or display -1/0
Input validation is not necessary, assume
a
is a natural number.Standard loopholes apply (Hardcoding, using a language created after this challenge)
Examples:
a=34, b=8 (272)
a=628, b=78 (48984)
a=15, b=35 (525)
a=33, b=1 (33)
a=20, (Error, -1, or 0)
How do we know if the input has a solution or not? Or is figuring that out part of the challenge? – Luis Mendo – 2017-01-10T12:07:20.313
As far as I can tell, only multiples of 10 do not have solutions. – Julian Lachniet – 2017-01-10T12:07:56.353
Do we have to "detect" that there is no solution or can we e.g. go into an infinite loop which will eventually throw an error? – Fatalize – 2017-01-10T12:29:47.340
Some are harder to find (powers of 3), I needed some time for 243 and 729, but it seems to work for every n given enough time – G B – 2017-01-10T12:30:45.687
2Related Math.SE post. Yes, every number that isn't a multiple of 10 has a palindromic multiple. – Martin Ender – 2017-01-10T12:33:43.830
@JulianLachniet hey, you seems to like a leaderboard on your question, you can just copy the one in
Pyramid of broken strings
, change theQUESTION_ID
andOVERRIDE_USER
to this question id (106336) and to your id (well that question is yours too, so you don't need to change this one) – Rod – 2017-01-10T12:37:10.390Can someone explain how to contact a moderator about reopening this question? – Julian Lachniet – 2017-01-10T13:53:56.490
4@JulianLachniet Having
a*b=c
wherea
is given andc
is a palindrome, your question asks to output 'b', the linked question asks to output 'c'. There is really very little difference... – steenbergh – 2017-01-10T14:14:41.410