Happy numbers: Difference between revisions

Happy numbers in BASIC256
m (→‎{{header|Picat}}: Added {{out}})
(Happy numbers in BASIC256)
Line 990:
return tot
}</lang>
 
=={{header|BASIC256}}==
<lang freebasic>n = 1 : cnt = 0
print "The first 8 isHappy numbers are:"
print
 
while cnt < 8
if isHappy(n) = 1 then
cnt += 1
print cnt; " => "; n
end if
n += 1
end while
 
function isHappy(num)
isHappy = 0
cont = 0
while cont < 50 and isHappy <> 1
num$ = string(num)
cont += 1
isHappy = 0
for i = 1 to length(num$)
isHappy += int(mid(num$,i,1)) ^ 2
next i
num = isHappy
end while
end function</lang>
 
=={{header|Batch File}}==
2,148

edits