私はPPCGでもう一つのプライムチャレンジが来るのを見ました。私はいくつかの素数を愛しています。その後、私は入門書を間違って読んで、ここの創造的な頭脳が何を思いついたのか疑問に思いました。
それは些細な問題だと判明しましたが、私が(誤って)読む質問にも同じことが当てはまるのだろうかと思います。
6は2 ^ 1 * 3 ^ 1で表すことができ、50は2 ^ 1 * 5 ^
2で表すことができます(^は指数を表します)。
あなたのタスク:
数値のこの表現にいくつの異なる素数が存在するかを決定するプログラムまたは関数を記述します。
入力:
An integer n such that 1 < n < 10^12, taken by any normal
method.
出力:
nの固有素因数を表す必要な別個の素数の数。
テストケース:
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)
これはOEISシーケンスではありません。
得点:
This is code-golf, lowest score in bytes wins!
ベストアンサー
05AB1E, 9 bytes
ÓDpÏsfìÙg
説明
Ó # prime factor exponents of input
DpÏ # keep only primes
sfì # prepend prime factors of input
Ù # remove duplicates
g # get length