aUCBLogo Demos and Tests / longinttest5
to longinttest5
local [i t1 t2 n fn]
ct setLoadNoisily true
load "Longint.lg
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
pr :result
(pr count :result "digits "in (:t2-:t1)/1000 "s)
pr "
]
]
noDribble
pr "Finished.
end
to func :n :fn
case :fn
[ [0 op LongDiv :n 3]
[1 op LongMod :n 3]
[2 if continue? ==wxYes [op LongPower 2 :n]]
[3 if continue? ==wxYes [op factorial :n]]
]
op -1
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?
ignore (MessageBox [Continue with next step?][MessageBox]
wxYes_No+wxCancel [400 200])
op wxYes
end