Home primes: Difference between revisions
Changed iteration count from count-up to count-down to better match wikipedia. Update for modified reqs.
(Added Wren) |
Thundergnat (talk | contribs) (Changed iteration count from count-up to count-down to better match wikipedia. Update for modified reqs.) |
||
Line 1:
{{Clarified-review}}
{{draft task}}
{{Wikipedia|Home prime}}
<br>
In number theory, the '''home prime HP(n)''' of an integer '''n''' greater than 1 is the prime number obtained by repeatedly factoring the increasing concatenation of prime factors including repetitions.
The traditional notation has the prefix "HP" and a postfix
Prime numbers are their own Home prime;
Line 15 ⟶ 18:
HP7 = 7
If the integer obtained by concatenating increasing prime factors is not prime, iterate
HP4(2) = HP22(1) = 211
HP4(2) = 2 × 2 => 22; HP22(1) = 2 × 11 => 211; 211 is prime
HP10(4) = HP25(
HP10(4) = 2 × 5 => 25; HP25(
Line 90 ⟶ 93:
for flat 2..20, 65 -> $m {
my ($n
@steps.push: $n = @factors.join.Int while (@factors = prime-factors $n) > 1;
my $step = +@steps;
say
(+@steps > 1 ?? '' !! "HP$m"), " = ", @steps.tail;
}</lang>
{{out}}
<pre>HP2 = 2
HP3 = 3
HP4(2) = HP22(1
HP5 = 5
HP6
HP7 = 7
HP8(13) = HP222(
HP9(2) = HP33(1
HP10(4) = HP25(
HP11 = 11
HP12
HP13 = 13
HP14(5) = HP27(
HP15(4) = HP35(
HP16(4) = HP2222(
HP17 = 17
HP18
HP19 = 19
HP20(15) = HP225(
HP65(19) = HP513(
=={{header|Wren}}==
|