aUCBLogo Demos and Tests / longinttest
to longinttest
local [i t1 t2 n fn]
ct longint; LoadLib "LongInt
nodribble dribble "longinttest.txt
forever
[ erase [i t1 t2 n fn]
make "fn getSingleChoiceIndex
[Choose function][get Single Choice]
[[LongDiv][LongMod][LongPower][Factorial][Stop]]
if (:fn==-1) or2 (:fn==4) [pr "Stopped. stop]
for [i 1 3 1]
[ make "n chain 3 :i pr :i pr :n
make "t1 timemilli
make "result func :n :fn
if :result==-1 [pr "Broken. break]
make "t2 timemilli
show :result
(pr count :result "digits "in (:t2-:t1)/1000 "s)
pr "
]
]
nodribble
pr "Finished.
end
to func :n :fn
case :fn
[ [1 op LongDiv :n 3]
[2 op LongMod :n 3]
[3 if continue? ==2 [op LongPower 2 :n]]
[4 if continue? ==2 [op factorial :n]]
] op -1 break
end
to factorial :n
if equalp :n 0 [output 1]
output LongProd :n factorial LongSub :n 1
end
to chain :ding :times
local [a] a=" repeat :times [make "a word :ding :a] op :a
end
to continue?
op (MessageBox [Continue with next step?][MessageBox]
wxYes_No+wxCancel [400 200])
end