Fermat numbers

func fermat_number(n) {
    2**(2**n) + 1
}

func fermat_one_factor(n) {
    fermat_number(n).ecm_factor
}

for n in (0..9) {
    say "F_#{n} = #{fermat_number(n)}"
}

say ''

for n in (0..13) {
    var f = fermat_one_factor(n)
    say ("F_#{n} = ", join(' * ', f.shift,
      f.map { <C P>[.is_prime] + .len }...))
}

Output:

F_0 = 3
F_1 = 5
F_2 = 17
F_3 = 257
F_4 = 65537
F_5 = 4294967297
F_6 = 18446744073709551617
F_7 = 340282366920938463463374607431768211457
F_8 = 115792089237316195423570985008687907853269984665640564039457584007913129639937
F_9 = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084097

F_0 = 3
F_1 = 5
F_2 = 17
F_3 = 257
F_4 = 65537
F_5 = 641 * P7
F_6 = 274177 * P14
F_7 = 59649589127497217 * P22
F_8 = 1238926361552897 * P62
F_9 = 2424833 * C148
F_10 = 45592577 * C301
F_11 = 319489 * C612
F_12 = 114689 * C1228
F_13 = 2710954639361 * C2454