Happy numbers: Difference between revisions
→{{header|UNIX Shell}}: Make solution compatible with ksh and zsh.
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
(→{{header|UNIX Shell}}: Make solution compatible with ksh and zsh.) |
||
Line 6,713:
=={{header|UNIX Shell}}==
{{works with|Bourne Again SHell}}
{{works with|Korn Shell}}
<syntaxhighlight lang="bash">#!/bin/bash▼
{{works with|Z Shell}}
while (( n )); do
done
}
function is_happy
typeset -i n=$1
while (( n != 1 )); do
if [[ -n
return 1
fi
seen[$n]=1
done
return 0
}
function first_n_happy {
printf '%d\n' "$n"
▲ if is_happy? "$n"; then
▲ let count-=1
done
return 0
}
first_n_happy 8</
=={{header|Ursala}}==
|