print "Part 1: Create a routine to generate the hailstone sequence for a number." print "" while hailstone < 1 or hailstone <> int(hailstone) input "Please enter a positive integer: "; hailstone wend count = doHailstone(hailstone,"Y") print: print "Part 2: Use the routine to show that the hailstone sequence for the number 27 has 112 elements starting with 27, 82, 41, 124 and ending with 8, 4, 2, 1." count = doHailstone(27,"Y") print: print "Part 3: Show the number less than 100,000 which has the longest hailstone sequence together with that sequence's length.(But don't show the actual sequence)!" print "Calculating result... Please wait... This could take a little while..." print "Stone Percent Count" for i = 1 to 99999 count = doHailstone(i,"N") if count > maxCount then theBigStone = i maxCount = count print using("#####",i);" ";using("###.#", i / 99999 * 100);"% ";using("####",count) end if next i end '--------------------------------------------- ' pass number and print (Y/N) FUNCTION doHailstone(hailstone,prnt$) if prnt$ = "Y" then print print "The following is the 'Hailstone Sequence' for number:";hailstone end if while hailstone <> 1 if (hailstone and 1) then hailstone = (hailstone * 3) + 1 else hailstone = hailstone / 2 doHailstone = doHailstone + 1 if prnt$ = "Y" then print hailstone;chr$(9); if (doHailstone mod 10) = 0 then print end if wend END FUNCTION