/* NetRexx */ options replace format comments java crossref symbols nobinary import RHailstoneSequence runSample(arg) return -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method runSample(arg) private static parse arg beginNum endNum . if beginNum = '' | beginNum = '.' then beginNum = 1 if endNum = '' | endNum = '.' then endNum = 100000 if beginNum > endNum then signal IllegalArgumentException('Gronk!') -- collect sequences hailstones = 0 loop hn = beginNum while hn < endNum hslist = RHailstoneSequence.hailstone(hn) hscount = hslist.words() hailstones[hscount] = hailstones[hscount] + 1 end hn -- locate most common mostOftenNum = 0 mostOftenCount = 0 loop hn = beginNum while hn < endNum if hailstones[hn] > mostOftenCount then do mostOftenCount = hailstones[hn] mostOftenNum = hn end end hn say 'The length of hailstone sequence that is most common in the range' beginNum '<= N <' endNum 'is' mostOftenNum'. It occurs' mostOftenCount 'times.' return