Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 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