Minimum positive multiple in base 10 using only 0 and 1: Difference between revisions
Minimum positive multiple in base 10 using only 0 and 1 (view source)
Revision as of 17:27, 11 February 2022
, 2 years agoJ: handle 1 exception differently (less efficient when y=1, but demonstrates the underlying equalities (and efficiency when y=1 is not a problem))
m (→{{header|J}}) |
m (J: handle 1 exception differently (less efficient when y=1, but demonstrates the underlying equalities (and efficiency when y=1 is not a problem))) |
||
Line 1,240:
<lang J>B10=: {{ NB. https://oeis.org/A004290
next=. {{ {: (u -) 10x^# }}
step=. ([>. [ {~ y|(i.y)+]) next
continue=. 0 = ({~y|]) next
L=.
k=. y|-r=.10x^<:#L
for_j. i.-<:#L do.
Line 1,252 ⟶ 1,251:
end.
end. r assert. 0=y|r
}}</lang>
Task example:
|