Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Prime-decomposition/PureBasic/prime-decomposition.basic
Normal file
34
Task/Prime-decomposition/PureBasic/prime-decomposition.basic
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
CompilerIf #PB_Compiler_Debugger
|
||||
CompilerError "Turn off the debugger if you want reasonable speed in this example."
|
||||
CompilerEndIf
|
||||
|
||||
Define.q
|
||||
|
||||
Procedure Factor(Number, List Factors())
|
||||
Protected I = 3
|
||||
While Number % 2 = 0
|
||||
AddElement(Factors())
|
||||
Factors() = 2
|
||||
Number / 2
|
||||
Wend
|
||||
Protected Max = Number
|
||||
While I <= Max And Number > 1
|
||||
While Number % I = 0
|
||||
AddElement(Factors())
|
||||
Factors() = I
|
||||
Number/I
|
||||
Wend
|
||||
I + 2
|
||||
Wend
|
||||
EndProcedure
|
||||
|
||||
Number = 9007199254740991
|
||||
NewList Factors()
|
||||
time = ElapsedMilliseconds()
|
||||
Factor(Number, Factors())
|
||||
time = ElapsedMilliseconds()-time
|
||||
S.s = "Factored " + Str(Number) + " in " + StrD(time/1000, 2) + " seconds."
|
||||
ForEach Factors()
|
||||
S + #CRLF$ + Str(Factors())
|
||||
Next
|
||||
MessageRequester("", S)
|
||||
Loading…
Add table
Add a link
Reference in a new issue