Finds a formula for
any sequence of numbers of
any length. The length is specified by you!
Uncompressed:
sync on : sync rate 0
input "Enter number of numbers: ",nons
dim numbers#(nons,nons-1)
dim numbers2#(nons,nons-1)
dim numbers3#(nons)
for d = 1 to nons
temp$ = str$(d) + " : "
input temp$, tempnum#
numbers#(d,0) = tempnum#
numbers2#(d,0) = numbers#(d,0)
next d
for d = 1 to nons-1
gosub finddiffs
power# = nons-d
number# = numbers2#(1,power#)
for dv = power# to 1 step -1
number# = number#/dv
next dv
if number# > 1
if power# > 1
Formula$ = Formula$ + "+" + str$(number#) + "n^" + str$(power#)
else
Formula$ = Formula$ + "+" + str$(number#) + "n"
endif
endif
if number# = 1
if power# > 1
Formula$ = Formula$ + "+n^" + str$(power#)
else
Formula$ = Formula$ + "+n"
endif
endif
gosub fillnew
next d
gosub finddiffs
if numbers2#(1,0) <> 0
if numbers2#(1,0) > 0
Formula$ = Formula$ + "+" + str$(numbers2#(1,0))
else
Formula$ = Formula$ + str$(numbers2#(1,0))
endif
endif
Formula$ = right$(Formula$,len(Formula$) - 1)
print Formula$
sync
suspend for key
end
finddiffs:
for f = 1 to nons-1
for a = 1 to nons - f
numbers2#(a,f) = numbers2#(a+1,f-1)-numbers2#(a,f-1)
next a
next f
return
fillnew:
for n = 1 to nons
numbers2#(n,0) = numbers2#(n,0) - (number#*(n^power#))
next n
return
compressed:
sync on : sync rate 0 : input "Enter number of numbers: ",nons : dim numbers#(nons,nons-1) : dim numbers2#(nons,nons-1) : dim numbers3#(nons)
for d = 1 to nons : temp$ = str$(d) + " : " : input temp$, tempnum# : numbers#(d,0) = tempnum# : numbers2#(d,0) = numbers#(d,0) : next d
for d = 1 to nons-1
gosub finddiffs : power# = nons-d : number# = numbers2#(1,power#)
for dv = power# to 1 step -1 : number# = number#/dv : next dv
if number# > 1 : if power# > 1 : Formula$ = Formula$ + "+" + str$(number#) + "n^" + str$(power#) : else : Formula$ = Formula$ + "+" + str$(number#) + "n" : endif : endif
if number# = 1 : if power# > 1 : Formula$ = Formula$ + "+n^" + str$(power#) : else : Formula$ = Formula$ + "+n" : endif : endif
gosub fillnew : next d : gosub finddiffs
if numbers2#(1,0) <> 0 : if numbers2#(1,0) > 0 : Formula$ = Formula$ + "+" + str$(numbers2#(1,0)) : else : Formula$ = Formula$ + str$(numbers2#(1,0)) : endif : endif : Formula$ = right$(Formula$,len(Formula$) - 1) : print Formula$ : sync
suspend for key : end
finddiffs:
for f = 1 to nons-1
for a = 1 to nons - f
numbers2#(a,f) = numbers2#(a+1,f-1)-numbers2#(a,f-1)
next a
next f : return
fillnew:
for n = 1 to nons
numbers2#(n,0) = numbers2#(n,0) - (number#*(n^power#))
next n : return
Plz tell me of any bugs. If there are any
There are three types of people, those that can count and those that can't.