Pisano period: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
(A)
Line 1,434: Line 1,434:
48 216 328 120 40 168 336 48 364 180
48 216 328 120 40 168 336 48 364 180
72 264 348 168 400 120 232 132 178 120</pre>
72 264 348 168 400 120 232 132 178 120</pre>

=={{header|Quackery}}==

<code>primefactors</code> is defined at [[Prime decomposition#Quackery]].

<code>lcm</code> is defined at [[Least common multiple#Quackery]].

<syntaxhighlight lang="Quackery"> [ dip number$
over size -
space swap of
swap join echo$ ] is recho ( n n --> )

[ witheach
[ 4 recho
i^ 1+ 10 mod
0 = if cr ] ] is prettyecho ( [ --> )

[ primefactors size 1 = ] is isprime ( n --> b )

[ dup [] = if done
[] [] rot
witheach
[ over [] = iff
join done
over 0 peek over = iff
join done
dip [ nested join ]
nested ]
nested join ] is runs ( [ --> [ )

[ stack ] is modulus ( --> s )

[ dip dup 1 - **
swap dup 2 < iff
[ 2drop 1 ] done
modulus put
0 temp put
0 1
[ 1 temp tally
tuck +
modulus share mod
dup 1 = until
over 0 = until ]
2drop
modulus release
temp take * ] is pisanoprime ( n n --> n )

[ dup 2 < iff
[ drop 1 ] done
primefactors
runs
[] swap
witheach
[ dup 0 peek
swap size
pisanoprime
join ]
behead swap
witheach lcm ] is pisano ( n --> n )

[] 15 times
[ i^ isprime if
[ i^ 2 pisanoprime
join ] ]
prettyecho
cr cr
[] 180 times
[ i^ isprime if
[ i^ 1 pisanoprime
join ] ]
prettyecho
cr cr
[] 180 times
[ i^ 1+ pisano join ]
prettyecho</syntaxhighlight>

{{out}}

<pre> 6 24 100 112 110 364

3 8 20 16 10 28 36 18 48 14
30 76 40 88 32 108 58 60 136 70
148 78 168 44 196 50 208 72 108 76
256 130 276 46 148 50 316 328 336 348
178

1 3 8 6 20 24 16 12 24 60
10 24 28 48 40 24 36 24 18 60
16 30 48 24 100 84 72 48 14 120
30 48 40 36 80 24 76 18 56 60
40 48 88 30 120 48 32 24 112 300
72 84 108 72 20 48 72 42 58 120
60 30 48 96 140 120 136 36 48 240
70 24 148 228 200 18 80 168 78 120
216 120 168 48 180 264 56 60 44 120
112 48 120 96 180 48 196 336 120 300
50 72 208 84 80 108 72 72 108 60
152 48 76 72 240 42 168 174 144 120
110 60 40 30 500 48 256 192 88 420
130 120 144 408 360 36 276 48 46 240
32 210 140 24 140 444 112 228 148 600
50 36 72 240 60 168 316 78 216 240
48 216 328 120 40 168 336 48 364 180
72 264 348 168 400 120 232 132 178 120
</pre>


=={{header|Raku}}==
=={{header|Raku}}==