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\times3^1\$, and \$50\$ can be represented by \$2^1\times5^2\$.
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!
64
? Is it2 (2,3)
(as 6 can be represented as 2*3) or1 (2)
(ignore the 6)? \$\endgroup\$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. \$\endgroup\$