# Perl Weekly Challenge 041

Both parts this week were numerical computations. For Part 1 we generate so called attractive numbers which are numbers whose count of prime factors is itself prime. Part 2 generates Leonardo Numbers

## Part 1

### Sample Run

\$ perl perl/ch-1.pl
4 (2, 2)
6 (2, 3)
8 (2, 2, 2)
9 (3, 3)
10 (2, 5)
12 (2, 2, 3)
14 (2, 7)
15 (3, 5)
18 (2, 3, 3)
20 (2, 2, 5)
21 (3, 7)
22 (2, 11)
25 (5, 5)
26 (2, 13)
27 (3, 3, 3)
28 (2, 2, 7)
30 (2, 3, 5)
32 (2, 2, 2, 2, 2)
33 (3, 11)
34 (2, 17)
35 (5, 7)
38 (2, 19)
39 (3, 13)
42 (2, 3, 7)
44 (2, 2, 11)
45 (3, 3, 5)
46 (2, 23)
48 (2, 2, 2, 2, 3)
49 (7, 7)
50 (2, 5, 5)

### What I Did

I think this is straightforward enough except for maybe one detail. I simply loop over all numbers between 1 and 50, compute the prime factors, and if the number of prime factors is itself prime then display the result. The only "trick", if you could even really call it that, is to pass the number of factors to the same prime_factor() function and if the number of factors is 1 then we know that the number of factors is prime, as required.

## Part 2

### Sample Run

\$ perl perl/ch-2.pl
L(0) = 1
L(1) = 1
L(2) = 3
L(3) = 5
L(4) = 9
L(5) = 15
L(6) = 25
L(7) = 41
L(8) = 67
L(9) = 109
L(10) = 177
L(11) = 287
L(12) = 465
L(13) = 753
L(14) = 1219
L(15) = 1973
L(16) = 3193
L(17) = 5167
L(18) = 8361
L(19) = 13529

### What I Did

The computations follow directly from the definition. I resisted any urge to golf or obfuscate the solution!

Comments for this post were locked by the author