Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Hamming-numbers/PureBasic/hamming-numbers.basic
Normal file
29
Task/Hamming-numbers/PureBasic/hamming-numbers.basic
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#X2 = 2
|
||||
#X3 = 3
|
||||
#X5 = 5
|
||||
|
||||
Macro Ham(w)
|
||||
PrintN("H("+Str(w)+") = "+Str(Hamming(w)))
|
||||
EndMacro
|
||||
|
||||
Procedure.i Hamming(l.i)
|
||||
Define.i i,j,k,n,m,x=#X2,y=#X3,z=#X5
|
||||
Dim h.i(l) : h(0)=1
|
||||
For n=1 To l-1
|
||||
m=x
|
||||
If m>y : m=y : EndIf
|
||||
If m>z : m=z : EndIf
|
||||
h(n)=m
|
||||
If m=x : i+1 : x=#X2*h(i) : EndIf
|
||||
If m=y : j+1 : y=#X3*h(j) : EndIf
|
||||
If m=z : k+1 : z=#X5*h(k) : EndIf
|
||||
Next
|
||||
ProcedureReturn h(l-1)
|
||||
EndProcedure
|
||||
|
||||
OpenConsole("Hamming numbers")
|
||||
For h.i=1 To 20
|
||||
Ham(h)
|
||||
Next
|
||||
Ham(1691)
|
||||
Input()
|
||||
Loading…
Add table
Add a link
Reference in a new issue