Files
project_euler/26/main.ua

15 lines
419 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# project euler 26
# divide a by b, doing one iteration of long division.
# ? b a
Div ← ×10-⊸(×⌊⤚÷)
# we will have to perform long division at most 1000
# times, so just do it 1000 times for all numbers
# below 1000, pervasively.
# use the steps to determine cycle lengths.
1000
⍥⟜⊸Div⟜⊃⇡(↯⊙1) # pervasively repeat long division.
⊢⍖≡(⧻◴)⍉ # cycle length is dedup length.