27 lines
775 B
Text
27 lines
775 B
Text
define hamming use $limit
|
|
[ ] as $h
|
|
1 $h 0 set
|
|
2 as $x2 3 as $x3 5 as $x5
|
|
0 as $i 0 as $j 0 as $k
|
|
1 $limit 1 + 1 range each as $n
|
|
$x3 $x5 min $x2 min $h $n set
|
|
$h $n get $x2 = if
|
|
$i 1 + as $i
|
|
$h $i get 2 * as $x2
|
|
$h $n get $x3 = if
|
|
$j 1 + as $j
|
|
$h $j get 3 * as $x3
|
|
$h $n get $x5 = if
|
|
$k 1 + as $k
|
|
$h $k get 5 * as $x5
|
|
$h $limit 1 - get
|
|
|
|
1 21 1 range each as $lim
|
|
$lim hamming print " " print
|
|
"\n" print
|
|
|
|
"Hamming(1691) is: " print 1691 hamming print "\n" print
|
|
|
|
# Raven can't handle > 2^31 using integers
|
|
#
|
|
#"Hamming(1000000) is: " print 1000000 hamming print "\n" print
|