Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Happy-numbers/BASIC256/happy-numbers.basic
Normal file
25
Task/Happy-numbers/BASIC256/happy-numbers.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue