comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Persson" <spam-away@nowhere.nil>
Subject: Re: invalid parameter list
Date: Sat, 18 Feb 2006 14:34:54 GMT
Date: 2006-02-18T14:34:54+00:00	[thread overview]
Message-ID: <igGJf.45328$d5.201713@newsb.telia.net> (raw)
In-Reply-To: <1140249851.389233.273980@g47g2000cwa.googlegroups.com>

isaac2004 wrote:
> the output for this is writing the chains to a txt file and then
> outputting them on the screen. my loop would look something like this
> 
> for N Start.. Stop loop
> 
> Sociable_Chain ( N, Max) ;
> 
> end loop;
> 
> that is how am i thinking will this be buggy or what

You can do the writing either inside Sociable_Chain or in another 
procedure. If you'll do it in another procedure you'll need to get the 
whole array out of Sociable_Chain and pass it to that other procedure.

>    function Sum_Of_Divisors (
>          N : Integer)
>      return Integer is
>       C   : Integer;
>       Sum : Integer;
> 
>    begin
>       Sum := 1;
>       C:=2;
>       while C**2 <= N loop --Number
> 
>          if N mod C = 0 then
>             if C * 2 = N then
>                Sum := Sum + C;
>             else
>                Sum := Sum + C + N / C;
>             end if;
>          end if;
>          C := C + 1 ;
>       end loop;
>       return Sum ;
> 
>    end Sum_Of_Divisors;

If I call this function with N=9 it will return 7. Is that really right?

Why Integer? What should the function return if N is -38? (What are the 
proper divisors of 1 or 0 anyway?)

-- 
Bj�rn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu



  reply	other threads:[~2006-02-18 14:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 23:13 invalid parameter list isaac2004
2006-02-18  6:02 ` jimmaureenrogers
     [not found] ` <tfadv19pqf17h3prdhquk3e5f30j6vhdhl@4ax.com>
2006-02-18  8:04   ` isaac2004
2006-02-18 14:34     ` Björn Persson [this message]
2006-02-18 21:19       ` isaac2004
2006-02-18 23:31         ` Björn Persson
2006-02-18 23:34           ` Martin Dowie
2006-02-19  0:06             ` isaac2004
     [not found]               ` <dmlfv11b4qagaf3gec853k9on191576gqc@4ax.com>
2006-02-19  4:06                 ` isaac2004
     [not found]                   ` <uavfv1pjdorpim6lpu8sjfdlq4lmmn1jes@4ax.com>
2006-02-19 16:21                     ` Björn Persson
2006-02-19 15:54               ` Björn Persson
2006-02-19  0:15             ` Ada.Text_IO.Create (was: invalid parameter list) Björn Persson
2006-02-19  8:14               ` Ada.Text_IO.Create Martin Dowie
2006-02-19 19:45                 ` Ada.Text_IO.Create Jeffrey R. Carter
2006-02-19 21:49                   ` Ada.Text_IO.Create Larry Kilgallen
2006-02-20  6:09                     ` Ada.Text_IO.Create isaac2004
2006-02-20  6:43                       ` Ada.Text_IO.Create Gautier
     [not found]                       ` <3stiv1l39144oscbs5he2v6h5uvfmli03q@4ax.com>
2006-02-21 22:15                         ` Ada.Text_IO.Create isaac2004
2006-02-22  7:45                           ` Range error (was: Ada.Text_IO.Create) Björn Persson
2006-02-22  8:27                             ` Range error Björn Persson
replies disabled

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