Projekt

Obecné

Profil

Stáhnout (599 Bajtů) Statistiky
| Větev: | Revize:
1
#!/usr/bin/env node
2
var bn = require('bn.js');
3
var fs = require('fs');
4
var mr = require('../').create();
5

    
6
var num = '';
7
if (process.argv[2]) {
8
  num += fs.readFileSync(process.argv[2]);
9
  start(num);
10
} else {
11
  process.stdin.on('data', function(chunk) {
12
    num += chunk.toString().replace(/[^0-9a-f]/gi, '');
13
  });
14
  process.stdin.once('end', function() {
15
    start(num);
16
  });
17
}
18

    
19
function start(text) {
20
  var num = new bn(text, 16);
21

    
22
  var divisor = mr.getDivisor(num);
23
  if (!divisor)
24
    process.exit(1);
25
  if (divisor.cmpn(1) === 0)
26
    process.exit(0);
27

    
28
  console.log(divisor.toString(16));
29
}
    (1-1/1)