Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
EnableExplicit
|
||||
|
||||
Procedure.i SumDigits(Number.q, Base)
|
||||
If Number < 0 : Number = -Number : EndIf; convert negative numbers to positive
|
||||
If Base < 2 : Base = 2 : EndIf ; base can't be less than 2
|
||||
Protected sum = 0
|
||||
While Number > 0
|
||||
sum + Number % Base
|
||||
Number / Base
|
||||
Wend
|
||||
ProcedureReturn sum
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
PrintN("The sums of the digits are:")
|
||||
PrintN("")
|
||||
PrintN("1 base 10 : " + SumDigits(1, 10))
|
||||
PrintN("1234 base 10 : " + SumDigits(1234, 10))
|
||||
PrintN("fe base 16 : " + SumDigits($fe, 16))
|
||||
PrintN("f0e base 16 : " + SumDigits($f0e, 16))
|
||||
PrintN("")
|
||||
PrintN("Press any key to close the console")
|
||||
Repeat: Delay(10) : Until Inkey() <> ""
|
||||
CloseConsole()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue