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: Fri, 15 Sep 2023 16:42:38 +0100 Organization: A noiseless patient Spider Message-ID: <874jjvmoi9.fsf@bsb.me.uk> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="4742dca9d4b952760dd7dfa5b429dc5b"; logging-data="3484712"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zyvgoX0Im1uAbNMA3tVJaginR8z46xkQ=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:Tzj7LjVEQ+dJw6sL99xn04e69Ug= sha1:X/G4lIaS037qjxndfNaejMtXqKY= X-BSB-Auth: 1.d4ec49fadd4a48a6cc4c.20230915164238BST.874jjvmoi9.fsf@bsb.me.uk Xref: news.eternal-september.org comp.lang.ada:65659 List-Id: "CSYH (QAQ)" writes: > Now this time, I am facing trouble for problem #29. As I know integer > type is for 32 bits. but for this problem as me to find out the 2 ** > 100 and even 100 ** 100. I used python to get the answer correctly in > 5 minutes. > > context = [] > for a in range(2,101): > for b in range(2,101): > context.append(a**b) > len(list(set(context))) > > I know the algorithm is easy, but I am pretty interesting how to > calculate a large like it. Most of the Project Euler problems have solutions that are not always the obvious one (though sometimes the obvious one is the best). You can, of course, just use a big number type (or write your own!) but this problem can be solved without having to use any large numbers at all. -- Ben.