Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.forth Subject: Re: Rosetta Code: Happy numbers Date: Fri, 26 Aug 2016 18:07:40 -0700 Organization: A noiseless patient Spider Lines: 16 Message-ID: <87y43jow83.fsf@jester.gateway.pace.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="590ea01354cf4bcbcd857d7ebbd88128"; logging-data="15772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zhUUAfHrDA8hZgSj1mcJg" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:PzCUdVd4srw8pbzv6UNHBtZHncs= sha1:Nyfyb4l0UfW+ay5WFkGDcAEE6eE= Xref: csiph.com comp.lang.forth:50501 "WJ" writes: > $memory = Hash.new > def happy? n, seq=[] > result = > if $memory.include?(n) > ... many more lines of crap bloaty code Bleccch, how tasteless. : ssd ( n -- n ) 0 swap \ sum of squares of digits begin dup while 10 /mod swap dup * rot + swap repeat drop ; : happy ( n -- flag ) dup begin ssd swap ssd ssd swap 2dup = until drop 1 = ; : go ( n -- ) 0 swap 0 do begin 1+ dup happy until dup . loop ; 15 go => 15 go 1 7 10 13 19 23 28 31 32 44 49 68 70 79 82 ok