# 教你编程拿到小姐姐微信，然后...

2019-04-15

emmm......这是要走上人生巅峰了吗? 开始行动，一步一步来。

## 1、找到微信号

javascript代码：

```const isPrime = function (n) {
if (n < 2) {
return false;
}
const max = Math.sqrt(n);
for (let i = 3; i < max; i = i + 2) {
if (n % i === 0) {
return false;
}
}
return true;
};
const find2number = function (n) {
const max = Math.sqrt(n);
for (let b = 2; b <= max; b++) {
if (n % b === 0) {
if (isPrime(b)) {
const a = n / b;
if (isPrime(a)) {
return [a, b];
}
}
}
}
return false;
};
const r = find2number(707829217);
console.log("微信号：NY"+r[0]+r[1]);   // 微信号：NY866278171```

## 2、计算附加题

```const count2 = function (n, x) {
let sum = 0, factor = 1, higher = 0, current = 0, lower = 0, time = 1;
for (; Math.floor(n / factor) != 0; factor *= 10) {
higher = Math.floor(n / (factor * 10));
current = Math.floor((n / factor)) % 10;
lower = n - Math.floor((n / factor)) * factor;
if (factor > 1) { time = 0.5;
} else if (x % 2 === 0) { continue;}
if (x === 0) {  higher--;  }
if (current === x) {
let _t = factor === 1 ? 1 : Math.ceil(lower * time);
sum += higher * factor * time + _t;
} else if (current > x) {
sum += (higher + 1) * factor * time;
} else if (current < x) {
sum += higher * factor * time;
}
}
return sum;
};
console.log("附加题：" + count2(866278171,3));   // 附加题：441684627```

（仅需验证一次）