From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e3ba37c5a979fdcb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail From: "isaac2004" Newsgroups: comp.lang.ada Subject: Re: invalid parameter list Date: 18 Feb 2006 00:04:11 -0800 Organization: http://groups.google.com Message-ID: <1140249851.389233.273980@g47g2000cwa.googlegroups.com> References: <1140218028.145204.141420@z14g2000cwz.googlegroups.com> NNTP-Posting-Host: 67.170.5.168 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1140249856 27275 127.0.0.1 (18 Feb 2006 08:04:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 18 Feb 2006 08:04:16 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=67.170.5.168; posting-account=bWy1LAwAAAAtVkasDCH0ykMCBMNd-FcL Xref: g2news1.google.com comp.lang.ada:2949 Date: 2006-02-18T00:04:11-08:00 List-Id: so how do i preform a case test with a picked integer to test the function for bugs. do i just put it in a loop till all chains are found. 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 my whole code i like this after your help with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; procedure Assignment3 is --------------------------------------------------------------------- --| program that takes a range in the form of a minimum and maximum number, --| and prompts for the length, to find all sociable chains inside of the range --| to that desired chain --| Isaac Levin, Western Washington --| February 2006 --------------------------------------------------------------------------- Start : Natural; Stop : Natural range Start..Integer'Last; Max : Natural range 1 .. 30; -- start of function that takes the inputted number and finds the sum of the divisors -- function description function Sum_Of_Divisors ( N : Integer) return Integer; -- function body 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; procedure Sociable_Chain ( Start, Max : Natural) is A : array (1 .. 30) of Positive; I : Positive := 2; begin A(1) :=Start; -- makes first number of array the prompt number A(2) := Sum_Of_Divisors (A(1)); -- 2nd number in array is sum of divisors of prompt while I < Max and A (1) /= A(I) loop -- loop till length is reached and till A(I) = A(1) I:= I + 1; A(I) := Sum_Of_Divisors (A(I - 1)); end loop; end Sociable_Chain; begin Put(Item => "Please enter your starting integer."); Get(Item => Start); New_Line; Put(Item => " Please enter your ending integer."); Get(Item => Stop); New_Line; Put(Item => " Please enter the length of largest chain. "); Get(Item => Max); for N Start.. Stop loop Sociable_Chain ( N, Max) ; end loop; end Assignment3 ;