LoginSignup
0
0

More than 3 years have passed since last update.

javascript 問題集 No.20 数値をtoStringを使わずに2進数にする。

Last updated at Posted at 2020-12-03

数値を2で割り切れなかったら1、割り切れたら0。

まず、0と1を入れる配列。

割る数(商)を確認する配列。

for文を商が1以下になるまで回し続ける。

このような基盤が出来たら、あとは配列を逆に回して配列を反対にする。

consoleに.join("")して2進数の完成

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0