Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Binary-digits/Vim-Script/binary-digits.vim
Normal file
21
Task/Binary-digits/Vim-Script/binary-digits.vim
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
function Num2Bin(n)
|
||||
let n = a:n
|
||||
let s = ""
|
||||
if n == 0
|
||||
let s = "0"
|
||||
else
|
||||
while n
|
||||
if n % 2 == 0
|
||||
let s = "0" . s
|
||||
else
|
||||
let s = "1" . s
|
||||
endif
|
||||
let n = n / 2
|
||||
endwhile
|
||||
endif
|
||||
return s
|
||||
endfunction
|
||||
|
||||
echo Num2Bin(5)
|
||||
echo Num2Bin(50)
|
||||
echo Num2Bin(9000)
|
||||
Loading…
Add table
Add a link
Reference in a new issue