Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,33 @@
PROCEDURE Main()
LOCAL i := 8, nH := 0
? hb_StrFormat( "The first %d happy numbers are:", i )
?
WHILE i > 0
IF IsHappy( ++nH )
?? hb_NtoS( nH ) + " "
--i
ENDIF
END
RETURN
STATIC FUNCTION IsHappy( nNumber )
STATIC aUnhappy := {}
LOCAL nDigit, nSum := 0, cNumber := hb_NtoS( nNumber )
FOR EACH nDigit IN cNumber
nSum += Val( nDigit ) ^ 2
NEXT
IF nSum == 1
aUnhappy := {}
RETURN .T.
ELSEIF AScan( aUnhappy, nSum ) > 0
RETURN .F.
ENDIF
AAdd( aUnhappy, nSum )
RETURN IsHappy( nSum )