RosettaCodeData/Task/Gapful-numbers/FreeBASIC/gapful-numbers.basic

39 lines
816 B
Plaintext

function is_gapful( n as uinteger ) as boolean
if n<100 then return false
dim as string ns = str(n)
dim as uinteger gap = 10*val(mid(ns,1,1)) + val(mid(ns,len(ns),1))
if n mod gap = 0 then return true else return false
end function
dim as ulongint i = 100
dim as ushort c
print "The first thirty gapful numbers:"
while c<30
if is_gapful(i) then
c += 1
print i;" ";
end if
i += 1
wend
print : print
i = 1000000 : c = 0
print "The first fifteen gapful numbers above 999,999:"
while c<15
if is_gapful(i) then
c += 1
print i;" ";
end if
i += 1
wend
print : print
i = 1000000000 : c = 0
print "The first ten gapful numbers above 999,999,999:"
while c<10
if is_gapful(i) then
c += 1
print i;" ";
end if
i += 1
wend
print