26 lines
481 B
Plaintext
26 lines
481 B
Plaintext
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
|