Hamming numbers: Difference between revisions

m
Line 6,881:
[1] 2125764000
</pre>
 
=== Alternate version ===
The '''nextn''' R function provides the needed functionality:
 
<lang r>hamming <- function(n) {
a <- numeric(n)
a[1] <- 1
for (i in 2:n) {
a[i] <- nextn(a[i-1]+1)
}
a
}</lang>
 
'''Output'''
 
<pre> hamming(20)
[1] 1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36</pre>
 
=={{header|Racket}}==
1,336

edits