comp.lang.ada
 help / color / mirror / Atom feed
* help with starting a program (newbie)
@ 2006-02-16 21:47 isaac2004
  2006-02-17  9:28 ` Stephen Leake
  0 siblings, 1 reply; 4+ messages in thread
From: isaac2004 @ 2006-02-16 21:47 UTC (permalink / raw)


hello i am in a basic ada class and i have an assignment that asks to
find all sociable chains in a range defined by the user. A sociable
chain is a generalization of the notion of amicable pairs. More
precisely, a sociable chain is sequence of positive integers,  like
I(1), I(2), .. I(N)
in which (1) each element I (i) is equal to the sum of the proper
divisors of I(i-1) , (2)
I (N) = I (1) and (3) none of the integers between the I (1) and I (N)
are equal (if there are any
integers between the first and the last; for chains of length two,
i.e., perfect numbers, of
course there won't be). this is the thoery behind sociable chains.

the program will ask for 3 inputs from a user, them being a start of
the number range, an end of the numebr range, and finally a maximum
chain length.

Sample Run of Program
-----------------------------------
Start = 12000
Stop = 15000
Length = 30

after input program computes all possible chains in the range of
numbers with a maximum chain length of 30 numbers
example
This chain is 3 in
length.
12285
14595
12285
This chain is 6 in
length.
12496
14288
15472
14536
14264
12496
This chain is 6 in
length.
14264
12496
14288
15472
14536
14264
This chain is 6 in
length.
14288
15472
14536
14264
12496
14288
This chain is 29 in
length.
14316
19116
31704
47616
83328
177792
295488
629072
589786
294896
358336
418904
366556
274924
275444
243760
376736
381028
285778
152990
122410
97946
48976
45946
22976
22744
19916
17716
14316
This chain is 6 in
length.
14536
14264
12496
14288
15472
14536
This chain is 3 in
length.
14595
12285
14595

------------------------------------------------\
the program uses the idea from this function
function Sum_Of_Divisors (
         N : Natural )
     return Natural is

         Sum : Natural;

   begin
Sum := 0;
      for I in 1 .. N - 1 loop
           if  N rem I = 0 then
            Sum := Sum + I;
                 end if;
      end loop;
      return Sum;
   end Sum_Of_Divisors;

this program finds the sum of the divisors of any number entered. any
help with this program would be greatly appreciated. thank you

isaac




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-02-17 23:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-16 21:47 help with starting a program (newbie) isaac2004
2006-02-17  9:28 ` Stephen Leake
     [not found]   ` <1140193368.725447.184020@g44g2000cwa.googlegroups.com>
2006-02-17 18:05     ` isaac2004
2006-02-17 23:59       ` Björn Persson

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