Happy numbers: Difference between revisions

no edit summary
No edit summary
Line 6,936:
The 10,000,000th: 71,313,350
Computation time 19.235551 seconds.</pre>
 
=={{header|Vlang}}==
{{trans|go}}
<lang vlang>fn happy(h int) bool {
mut m := map[int]bool{}
mut n := h
for n > 1 {
m[n] = true
mut x := 0
for x, n = n, 0; x > 0; x /= 10 {
d := x % 10
n += d * d
}
if m[n] {
return false
}
}
return true
}
fn main() {
for found, n := 0, 1; found < 8; n++ {
if happy(n) {
print("$n ")
found++
}
}
println('')
}</lang>
{{out}}
<pre>
1 7 10 13 19 23 28 31
</pre>
 
=={{header|Wren}}==
338

edits