24
Given an positive integer as input determine if it is a magnanimous number.
A magnanimous number is a number such that any insertion of a +
sign between any two digits in base 10 results in an expression of a prime integer.
For example 40427 is magnanimous because
4+0427 = 431 is prime
40+427 = 467 is prime
404+27 = 431 is prime
4042+7 = 4049 is prime
Output
You should output two distinct values, one when the input is magnanimous and one when the input is not.
Scoring
The goal of this contest will be to make the size of the source code written to solve this task, given in bytes, as small as possible.
Test Cases
1 -> True
2 -> True
4 -> True
10 -> False
98 -> True
101 -> True
109 -> False
819 -> False
4063 -> True
40427 -> True
2000221 -> True
I'm just confused by the definition of the challenge how 1 and 2 are even valid inputs. Let alone the fact that
1
with a plus sign inserted between any two characters (no inserting) can only result in1
, which itself is not prime. – Magic Octopus Urn – 2017-06-27T15:30:16.7604@MagicOctopusUrn The plus must be inserted between two digits, thus since
1
and2
don't have two digits the set of expressions is empty. All of the members of the empty set are prime. In addition none of them are, but thats besides the point. It is a bit confusing, I'll give you that but I think it makes more sense than the alternatives. – Post Rock Garf Hunter – 2017-06-27T15:32:30.517