-3
For the purpose of this challenge, a multi-base prime is a prime which, when written in base 10, is prime in one or more bases smaller than 10 and larger than 1 as well. All single-digit primes are trivially multi-base primes. 11 is also a multi-base prime, as 11 in binary is 3, which is prime (it is also prime in base 4 and base 6). The first few terms are: 2,3,5,7,11,13, 17, 23,31,37,41,43,47,53,61...
Your Task:
Write a program or function that, when given an integer as input, returns/outputs a truthy value if the input is a multi-base prime, and a falsy value if it is not.
Input:
An integer between 1 and 10^12.
Output:
A truthy/falsy valule, depending on whether the input is a multi-base prime.
Test Cases:
3 -> truthy
4 -> falsy
13 -> truthy
2003 -> truthy (Also prime in base 4)
1037 -> falsy (2017 in base 5 but not a prime in base 10)
Scoring:
This is code-golf, lowest score in bytes wins!
Could you add a test case that's prime in base-2 and base-10 only? I haven't been able to find any such numbers yet but if any do exist, I'll need to update my solution. – Shaggy – 2017-10-10T11:15:32.580
3@Shaggy
173,1259,1277,2069,2099,2237,2797,2801,3331,3539,3541,3851,3929,3989,4261,4349,4373,5077,5087,5279,5399,6047,6269,6389...
– None – 2017-10-10T11:37:52.3271Thanks, @StraklSeth. I'd since found a couple but my solution needed to be updated anyway. – Shaggy – 2017-10-10T11:59:02.933
Isn't 17 a multi-base prime as well (
101
in base 4)? – ovs – 2017-10-10T14:44:56.193I concur that 17 seems to be a prime in bases 4, 6, and 10. – Peter Taylor – 2017-10-10T15:10:15.093
3The binary evaluation of
19
would be eleven (2^1×1+2^0×9=11), so it seems we are to explicitly ignore evaluating those possibilities that include "excessive digits" - is this correct? – Jonathan Allan – 2017-10-10T21:24:56.1471I nominated this question for reopening but I now realize it is unclear. I would like to see the "excessive digit" problem solved. – Post Rock Garf Hunter – 2017-10-10T23:06:22.910