From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.ada Subject: Re: project euler 29 Date: Mon, 18 Sep 2023 12:31:10 +0100 Organization: A noiseless patient Spider Message-ID: <87wmwnk9a9.fsf@bsb.me.uk> References: <874jjvmoi9.fsf@bsb.me.uk> <87sf7dltq0.fsf@bsb.me.uk> <87jzsplr49.fsf@bsb.me.uk> <715fe49a-47bc-46be-ae26-9ed89b38bcb5n@googlegroups.com> <87ediwl7oq.fsf@bsb.me.uk> <87zg1kpcjh.fsf@nightsong.com> <8734zcl4j0.fsf@bsb.me.uk> <87v8c8oyby.fsf@nightsong.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="4a1f049c3c0d7d3aa42e2e5e10f8a54b"; logging-data="1839543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T7XHjht7pJXy3onTbRhYVjMNwRrP4DE8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:32w+zvH0YRZE2DI+7OvIsHZvHLk= sha1:fZvG2XFDurwdUeqU6FxNA3m83dY= X-BSB-Auth: 1.87458021581c817cab5d.20230918123110BST.87wmwnk9a9.fsf@bsb.me.uk Xref: news.eternal-september.org comp.lang.ada:65675 List-Id: Paul Rubin writes: > Ben Bacarisse writes: >>> So you just loop through 1 <= a,b <= 100 and count only the a,b pairs >>> where a is the smallest a for its equivalence class. >> This is likely to be fast which is why I wanted to compile Francesc's to >> try it out. Mind you, a naive a^b == c^d test gives pretty good >> performance for the kind of range requested. > > But Francesc's program doesn't use that method. It only suggests it in > a comment. The program actually works by building a list, sorting it, > and counting the groups. I only looked briefly and thought it used the factor method to decide if the power is one that occurs earlier in the sequence. Two trivial things, starting with Answer as the full NxN count and then decrementing Answer made me think that was what it was doing. -- Ben.