26
2
Redivosite is a portmanteau word invented for the sole purpose of this challenge. It's a mix of Reduction, Division and Composite.
Definition
Given an integer N > 6:
- If N is prime, N is not a Redivosite Number.
- If N is composite:
- repeatedly compute N' = N / d + d + 1 until N' is prime, where d is the smallest divisor of N greater than 1
- N is a Redivosite Number if and only if the final value of N' is a divisor of N
Below are the 100 first Redivosite Numbers (no OEIS entry at the time of posting):
14,42,44,49,66,70,143,153,168,169,176,195,204,260,287,294,322,350,414,462,518,553,572,575,592,629,651,702,726,735,775,806,850,869,889,891,913,950,1014,1023,1027,1071,1118,1173,1177,1197,1221,1235,1254,1260,1302,1364,1403,1430,1441,1554,1598,1610,1615,1628,1650,1673,1683,1687,1690,1703,1710,1736,1771,1840,1957,1974,2046,2067,2139,2196,2231,2254,2257,2288,2310,2318,2353,2392,2409,2432,2480,2522,2544,2635,2640,2650,2652,2684,2717,2758,2760,2784,2822,2835
Examples
- N = 13: 13 is prime, so 13 is not a Redivosite Number
- N = 32: 32 / 2 + 3 = 19; 19 is not a divisor or 32, so 32 is not a Redivosite Number
- N = 260: 260 / 2 + 3 = 133, 133 / 7 + 8 = 27, 27 / 3 + 4 = 13; 13 is a divisor or 260, so 260 is a Redivosite Number
Your task
- Given an integer N, return a truthy value if it's a Redivosite Number or a falsy value otherwise. (You may also output any two distinct values, as long as they're consistent.)
- The input is guaranteed to be larger than 6.
- This is code-golf, so the shortest answer in bytes wins!
13I really wish all of these "number sequence" challenges that are just sequences of numbers with a certain property would just be asked as decision problems. I highly doubt there's any way to generate these directly, so the only possible solution is to solve the decision problem and then wrap it in a loop that finds the Nth or the first N or all integers that satisfy this property. – Martin Ender – 2018-01-04T15:41:47.860
3I like [tag:sequence] challenges that are not [tag:decision-problem]s in general, but for this one I think a [tag:decision-problem] would be a better fit. I see no relation between the terms such that you print the nth or the first n in a clever manner, so maybe allow taking n as input and checking if it is redivosite? – Mr. Xcoder – 2018-01-04T15:44:07.277
1@MartinEnder & Mr.Xcoder That was my initial intention (hence the original title which I've just rollbacked to) and I changed my mind. I guess this should not ruin any WIP solution (for the reasons you say), so I've edited it. – Arnauld – 2018-01-04T15:50:24.697
5@Mr.Xcoder Yeah, that's what I meant. I don't mind sequence challenges which actually make sense as a sequence (either because you can compute
a(n)
directly, or because you can compute a term from previous ones). Thanks, Arnauld, for changing the challenge. :) – Martin Ender – 2018-01-04T16:01:52.357