to sum_of_square_digits :number output (apply "sum (map [[d] d*d] ` :number)) end to is_happy? :number [:seen []] output cond [ [ [:number = 1] "true ] [ [member? :number :seen] "false ] [ else (is_happy? (sum_of_square_digits :number) (lput :number :seen))] ] end to n_happy :count [:start 1] [:result []] output cond [ [ [:count <= 0] :result ] [ [is_happy? :start] (n_happy (:count-1) (:start+1) (lput :start :result)) ] [ else (n_happy :count (:start+1) :result) ] ] end print n_happy 8 bye