UNPKG
mathball
Version:
latest (0.4.0)
0.4.0
0.3.1
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0
A JavaScript library for Competitive Programming
github.com/pbiswas101/Mathball
pbiswas101/Mathball
mathball
/
lib
/
magic
/
index.js
19 lines
(16 loc)
•
287 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict'
;
/* Magic Number * Function: magic() */
var
validate =
require
(
'../validation/positive-integer'
);
exports
.
find
=
function
(
num
) {
validate
(num,
'magic'
);
var
pow =
1
, res =
0
;
while
(num) { pow *=
5
; res += num &
1
? pow :
0
; num >>=
1
; }
return
res; };