39 lines
947 B
Text
39 lines
947 B
Text
Module hamming {
|
|
function hamming(l as long, &h(),&last()) {
|
|
l=if(l<1->1&, l)
|
|
oldlen=len(h())
|
|
if oldlen<l then dim h(l) else =h(l-1): exit
|
|
def decimal i, j, k, m, x2, x3, x5
|
|
stock last(0) out x2,x3,x5,i,j,k
|
|
n=oldlen : ll=l-1&
|
|
{ m=x2
|
|
if m>x3 then m=x3
|
|
if m>x5 then m=x5
|
|
h(n)=m
|
|
if n>=43207& then =h(n):break
|
|
if m=x2 then i++:x2=2@*h(i)
|
|
if m=x3 then j++:x3=3@*h(j)
|
|
if m=x5 then k++:x5=5@*h(k)
|
|
if n<ll then n++: loop
|
|
}
|
|
stock last(0) in x2,x3,x5,i,j,k
|
|
=h(ll)
|
|
}
|
|
dim h(1)=1@, last()
|
|
last()=(2@,3@,5@,0@,0@,0@)
|
|
Document doc$
|
|
const nl$={
|
|
}
|
|
for i=1 to 20
|
|
Doc$=format$("{0::-10} {1::-28}", i, hamming(i,&h(), &last()))+nl$
|
|
next i
|
|
i=1691
|
|
Doc$=format$("{0::-10} {1::-28}", i, hamming(i,&h(), &last()))+nl$
|
|
i=9999
|
|
Doc$=format$("{0::-10} {1::-28}", i, hamming(i,&h(), &last()))+nl$
|
|
i=43208
|
|
Doc$=format$("{0::-10} {1::-28}", i, hamming(i,&h(), &last()))+nl$
|
|
print #-2, Doc$
|
|
clipboard Doc$
|
|
}
|
|
hamming
|