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

33 lines
700 B
Text

c = 0
i = 1
print "The first 200 numbers are: "
while c < 10000001
if eqrf(i) = 1 then
c = c +1
if c <= 200 then
print using("### ", i);
if c mod 20 = 0 then print chr$(10)
end if
if c = 10000000 then print chr$(10); "The 10 000 000th number is "; i
end if
i = i + 1
wend
end
function eqrf(n)
sn$ = str$(n)
q = 0
for i = 2 to len(sn$)
if asc(mid$(sn$,i,1)) > asc(mid$(sn$,i-1,1)) then
q = q +1
end if
if asc(mid$(sn$,i,1)) < asc(mid$(sn$,i-1,1)) then
q = q -1
end if
next i
if q = 0 then
eqrf = 1
else
eqrf = 0
end if
end function