Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Binary-digits/S-BASIC/binary-digits.basic
Normal file
22
Task/Binary-digits/S-BASIC/binary-digits.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
rem - Return binary representation of n
|
||||
|
||||
function bin$(n = integer) = string
|
||||
var s = string
|
||||
s = ""
|
||||
while n > 0 do
|
||||
begin
|
||||
if (n - (n / 2) * 2) = 0 then
|
||||
s = "0" + s
|
||||
else
|
||||
s = "1" + s
|
||||
n = n / 2
|
||||
end
|
||||
end = s
|
||||
|
||||
rem - exercise the function
|
||||
|
||||
print "5 = "; bin$(5)
|
||||
print "50 = "; bin$(50)
|
||||
print "9000 = "; bin$(9000)
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue