' ' Darwin's elephants ' ' elephants live to > age 100, and female elephants produce one offspring ' every 10 years from the age of 30 through 80 ( 6 in all ). ' The sex of the offspring sequence is determined by SEX(0) - SEX(5), with ' 0 being male, 1 being female. ' ' POP( sex, age/10 ) carries the population for each sex and age group. ' ' If sex(0-3)=1, sex(4)=0, sex(5)=1 (1=female, 0= male) ' this produces almost exactly 15 million elephants after 500 years! ' This is the maximum population possible. ' ' DIM MALEPOP AS LONG DIM FEMALEPOP AS LONG DIM POP(1, 10) AS LONG POP(0, 0) = 1 'initial male population POP(1, 0) = 1 'initial female population RSTART = 3 ' min age (age/10) of reproduction RSTOP = 8 ' max age (age/10) of reproduction SEX(0) = 1 ' sex of offspring of female aged RSTART SEX(1) = 1 ' sex of offspring of female aged RSTART+1 SEX(2) = 1 ' sex of offspring of female aged RSTART+2 SEX(3) = 1 ' sex of offspring of female aged RSTART+3 SEX(4) = 0 ' sex of offspring of female aged RSTART+4 SEX(5) = 1 ' sex of offspring of female aged RSTART+5 PRINT "Years Male pop. Female pop. Total pop. Females/male." FOR DECADE = 1 TO 50 ' age the population by one decade, and count males aged RSTART to RSTOP ADULTMALEPOP = 0 FOR AGE = 10 TO 1 STEP -1 POP(0, AGE) = POP(0, AGE - 1) 'age the males by 10 years IF (AGE >= RSTART) AND (AGE <= RSTOP) THEN ADULTMALEPOP = ADULTMALEPOP + POP(0, AGE) END IF POP(1, AGE) = POP(1, AGE - 1) 'age the females by 10 years NEXT AGE POP(0, 0) = 0 'no newborn males yet POP(1, 0) = 0 'no newborn females yet ' if there are any male elephants, have each female between 30-80 ' produce a son or daughter. IF ADULTMALEPOP > 0 THEN FOR AGE = RSTART TO RSTOP POP(SEX(AGE - RSTART), 0) = POP(SEX(AGE - RSTART), 0) + POP(1, AGE) NEXT AGE END IF ' print populations for each decade MALEPOP = 0 FEMALEPOP = 0 FOR AGE = 0 TO 10 MALEPOP = MALEPOP + POP(0, AGE) FEMALEPOP = FEMALEPOP + POP(1, AGE) NEXT AGE PRINT DECADE * 10, STR$(MALEPOP), STR$(FEMALEPOP), STR$(MALEPOP + FEMALEPOP), IF MALEPOP > 0 THEN PRINT STR$(FEMALEPOP / MALEPOP); IF ADULTMALEPOP = 0 THEN PRINT " (no males)" ELSE PRINT NEXT DECADE END