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 26 Date: Mon, 04 Sep 2023 17:01:04 +0100 Organization: A noiseless patient Spider Message-ID: <878r9mudvj.fsf@bsb.me.uk> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="e2cb716c5442438ebe9264e332ee95d9"; logging-data="1627475"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0li7nHnLEANnMakgnsLh9DoNQskUnoBw=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:0zb1ocrDBOVgXvwdOm59plppnXg= sha1:l/oTWclUlbjJ7CKT88CTwII8foU= X-BSB-Auth: 1.9b27877351d9e45f752c.20230904170104BST.878r9mudvj.fsf@bsb.me.uk Xref: news.eternal-september.org comp.lang.ada:65591 List-Id: "Dmitry A. Kazakov" writes: > On 2023-09-04 13:06, Niklas Holsti wrote: >> On 2023-09-04 12:19, CSYH (QAQ) wrote: >>> I am new to Ada, I know is there a good way to start this program? >>> thanks >>> https://projecteuler.net/problem=26 >> First invent/discover the method (algorithm) for solving the problem, >> without thinking about the programming language. >> I don't think any language has built-in features that would lead to a >> direct solution, although some functional language with lazy evaluation >> could come close, because such languages can manipulate unbounded >> (potentially infinite) sequences of values. Such sequences can be handled >> in Ada, too, but with more effort -- they are not "built in" to Ada. > > Infinite division does not require big numbers, which Ada 22 has, but I > wound not use them anyway because the performance would be abysmal. > > BTW, Ada is perfect for numeric algorithms no need to resort to functional > mess... (:-)) Perfect? That's a bold claim! Mind you, I don't think this problem is really a numerical one in that sense. It needs some simple integer arithmetic but then every language is perfect for that sort of arithmetic. Using a functional mess (Haskell) a simple, native solution (i.e. using no modules) is only 9 lines long. I don't want to start a language war. Ada is just more 'wordy' by deliberate design so a simple Ada solution is inevitably going to be longer in terms of lines. Rather my purpose in posting is to steer the OP away from thinking of this as a numerical problem in the classical sense. It really isn't. -- Ben.