15
Inspired by this Numberphile entry
Background
The cube distance numbers of an integer n are defined here as the set of integers that are x³ distance away for a given x. For a simple example, with n=100
and x=2
, the cube distance numbers are {92,108}
.
This can be extended into a larger set simply by varying x. With x ∈ {1,2,3,4}
and the same n=100
, we have the resultant set {36,73,92,99,101,108,127,164}
.
Let's define CD(n,x) as the set of all integers n ± z³
with z ∈ {1,2,3,...,x}
.
Now we can focus on some of the special properties of these cube distance numbers. Of the many special properties that numbers can have, the two properties we're interested in here are primality and prime divisors.
For the above example CD(100,4), note that 73, 101, 127
are all prime. If we remove those from the set, we're left with {36,92,99,108,164}
. All prime divisors of these numbers are (in order) {2,2,3,3,2,2,23,3,3,11,2,2,3,3,3,2,2,41}
, which means we have 5 distinct prime divisors {2,3,23,11,41}
. We can therefore define that CD(100,4) has ravenity1 of 5
.
The challenge here is to write a function or program, in the fewest bytes, that outputs the ravenity of a given input.
Input
- Two positive integers,
n
andx
, in any convenient format.
Output
- A single integer describing the ravenity of the two input numbers, when calculated with CD(n,x).
Rules
- Input/output can be via any suitable method.
- Standard loophole restrictions apply.
- For ease of calculation, you can assume that the input data will be such that CD(n,x) will only have positive numbers in the set (i.e., no CD(n,x) will ever have negative numbers or zero).
- The function or program should be able to handle input numbers so that
n + x³
fits in your language's native integer data type. For example, for a 32-bit signed integer type, all input numbers withn + x³ < 2147483648
are possible.
Examples
n,x - output
2,1 - 0 (since CD(2,1)={1,3}, distinct prime divisors={}, ravenity=0)
5,1 - 2
100,4 - 5
720,6 - 11
Footnotes
1 - So named because we're not interested in the cardinality of the set, but a different type of bird. Since we're dealing with "common" divisors, I chose to use the common raven.
How does
100,4
yield 5? The cube distance numbers of that set are36,164
, and the prime factors of that set are2,3,41
(since the factors of that set are{2, 3, 4, 6, 9, 12, 18, 36}
and{2, 4, 41, 82, 164}
, respectively). Therefore, the output should be 3, not 5. – R. Kap – 2016-04-01T20:31:21.4102@R.Kap
100,4
is the example the OP explains in the Background section. Your mistake seems to be that you should consider all1..x
, so[1,2,3,4]
for this case. – FryAmTheEggman – 2016-04-01T20:33:32.417@FryAmTheEggman Oh. okay. I get it now. – R. Kap – 2016-04-01T20:34:35.060
Would it be pronounced [ruh-VEE-nuh-tee] (or /rəˈviːnəti/ for those of you who read IPA)? – Leaky Nun – 2016-04-02T05:23:32.623
1@KennyLau In my head, I pronounced it as "rah-VIN-eh-ty" – AdmBorkBork – 2016-04-04T14:41:01.590
I take it as a yes. – Leaky Nun – 2016-04-04T14:42:26.473