comp.lang.ada
 help / color / mirror / Atom feed
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: project euler 29
Date: Mon, 18 Sep 2023 01:16:19 +0100	[thread overview]
Message-ID: <8734zcl4j0.fsf@bsb.me.uk> (raw)
In-Reply-To: 87zg1kpcjh.fsf@nightsong.com

Paul Rubin <no.email@nospam.invalid> writes:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>> Also, do you have a different approach to solve this 29th problem?
>>
>> Yes, but it's not in Ada.  I implemented an equality test for a^b ==
>> c^d.
>
> Oh interesting, based on a comment in Francesc's code, I think I see a
> method to do it without the auxiliary array, at a small increase in
> runtime cost.  Basically given a and b, you can find their prime factors
> and easily enumerate the combinations x,y with a**b==x**y and
> 1 <= x,y <= 100.  You can label each "equivalence class" by the (a,b)
> with the smallest possible a.
>
> 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.  I might see if I
> can code this, which should also let me describe it more concisely.

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.

-- 
Ben.

  reply	other threads:[~2023-09-18  0:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15  9:03 project euler 29 CSYH (QAQ)
2023-09-15  9:50 ` Jeffrey R.Carter
2023-09-15 18:04   ` Keith Thompson
2023-09-15 15:42 ` Ben Bacarisse
2023-09-16 10:07   ` Francesc Rocher
2023-09-16 20:59     ` Ben Bacarisse
2023-09-16 21:56       ` Ben Bacarisse
2023-09-17 18:56         ` Francesc Rocher
2023-09-17 22:54           ` Paul Rubin
2023-09-17 23:08           ` Ben Bacarisse
2023-09-18  0:09             ` Paul Rubin
2023-09-18  0:16               ` Ben Bacarisse [this message]
2023-09-18  5:16                 ` Paul Rubin
2023-09-18 11:31                   ` Ben Bacarisse
2023-09-18 13:04                     ` Francesc Rocher
2023-09-18 14:20                       ` Ben Bacarisse
2023-09-18 16:55                         ` Francesc Rocher
2023-09-18 19:22                           ` Ben Bacarisse
2023-09-18 19:38                             ` Paul Rubin
2023-09-18 19:52                               ` comp.lang.ada
2023-09-18 19:56                                 ` comp.lang.ada
2023-09-18 20:01                               ` Ben Bacarisse
2023-09-15 16:34 ` Jeffrey R.Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox