* (c)2000 T N Channon let e6 = [100,150,220,330,470,680,1000] let e12 = [100,120,150,180,220,270,330,390,470,560,680,820,1000] let e24 = [100,110,120,130,150,160,180,200,220,240,270,300,330,360,390,430,470,510,560,620,680,750,820,910,1000] let e48 = [100,105,110,115,121,127,133,140,147,154,162,169,178,187,196,205,215,226,237,249,261,274,287,301,316,332,348,365,383,402,422,442,464,487,511,523,536,562,590,619,649,681,715,750,787,825,866,909,953,1000] let e96 = [100,102,105,107,110,113,115,118,121,124,127,130,133,137,140,143,147,150,154,158,162,165,169,174,178,182,187,191,196,200,205,210,215,221,226,232,237,243,249,255,261,267,274,280,287,294,301,309,316,324,332,340,348,357,365,374,383,392,402,412,422,432,442,453,464,475,487,499,511,523,536,549,562,576,590,604,619,634,649,665,681,698,715,732,750,768,787,806,825,845,866,887,909,931,953,976,1000] Arguments range value @answer let exp = 0 if value <= 100 then do while value < 100 let value = value * 10 let exp = exp + 1 loop else do while value >= 1000 let value = value / 10 let exp = exp - 1 loop endif *echo {range} if range = 'e6' then let eseries = e6 elseif range = 'e12' then let eseries = e12 elseif range = 'e24' then let eseries = e24 elseif range = 'e48' then let eseries = e48 elseif range = 'e96' then let eseries = e96 else let answer = value exit script endif let N = length(eseries) let first = 1 let last = N do while last >= first let i = Floor((first+last) / 2) if value < eseries[i-1] then let last = i-1 else let first = i + 1 endif loop *debug echo {last} {value} {exp} let crack = exp((ln(eseries[last-1])+ln(eseries[last]))/2) if value < crack then let answer = eseries[last-1] else let answer = eseries[last] endif if exp > 0 then do while exp > 0 let answer = answer / 10 let exp = exp - 1 loop else do while exp < 0 let answer = answer * 10 let exp = exp + 1 loop endif