RosettaCodeData/Task/Numbers-with-equal-rises-and-falls/Liberty-BASIC/numbers-with-equal-rises-and-falls.basic
2026-04-30 12:34:36 -04:00

37 lines
848 B
Text

print "The first 200 numbers are: "
i = 1
co = 0
while co < 10000001
if eqrf(i) = 1 then
co = co + 1
select case
case (co <= 200) and (co mod 10 <> 0)
print i; " ";
case (co <= 200) and (co mod 10 = 0)
print i; chr$(10);
case (co = 10000000)
print
print "The 10 000 000th number is "; i
end select
end if
i = i + 1
wend
end
function eqrf(n)
string$ = str$(n)
ca = 0
for i = 2 to len(string$)
if asc(mid$(string$,i,1)) > asc(mid$(string$,i-1,1)) then
ca = ca + 1
end if
if asc(mid$(string$,i,1)) < asc(mid$(string$,i-1,1)) then
ca = ca - 1
end if
next i
if ca = 0 then
eqrf = 1
else
eqrf = 0
end if
end function