9
1
I saw another prime challenge coming by in PPCG, and I do love me some primes. Then I misread the introductory text, and wondered what the creative brains here had come up with.
It turns out the question posed was trivial, but I wonder if the same is true of the question I (mis)read:
6 can be represented by 2^1*3^1, and 50 can be represented by 2^1*5^2 (where ^ indicates exponention).
Your task:
Write a program or function to determine how many distinct primes there are in this representation of a number.
Input:
An integer n such that 1 < n < 10^12, taken by any normal method.
Output:
The number of distinct primes that are required to represent the unique prime factors of n.
Test cases:
Input Factorisation Unique primes in factorisation representation
24 2^3*3^1 2 (2, 3)
126 2^1*3^2*7^1 3 (2, 3, 7)
8 2^3 2 (2, 3)
64 2^6 1 (2) (6 doesn't get factorised further)
72 2^3*3^2 2 (2, 3)
8640 2^6*3^3*5^1 3 (2, 3, 5)
317011968 2^11*3^5*7^2*13^1 6 (2, 3, 5, 7, 11, 13)
27 3^3 1 (3)
This is not an OEIS sequence.
Scoring:
This is code-golf, lowest score in bytes wins!
What is the expected result for
64
? Is it2 (2,3)
(as 6 can be represented as 2*3) or1 (2)
(ignore the 6)? – Emigna – 2017-10-09T12:38:01.493for
64
the expected result is 1 (2). I like the idea of doing it recursively, but that's not the way I read the original question. I thought8640
was a suitable test case, but should have been more explicit - thanks. – pbeentje – 2017-10-09T12:55:13.997You claim this is not an OEIS sequence. Is it not A001221, the values of the (small) omega function? – Gray Taylor – 2017-10-10T09:39:06.643
A001221 is similar, but starts to diverge at terms 8 and 9 (here 2, A001221 1) because of the inclusion of the exponent as prime in this exercise. – pbeentje – 2017-10-10T10:59:57.993
Ah, I see. Write down the prime factorisation, then see how many different primes I wrote (regardless of the role they played). I wonder what happens if you go a step further and factorise the exponent... – Gray Taylor – 2017-10-10T13:45:53.903