代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> 3n + 1 Game </title>
<style>
.cols {
display: flex;
}
.col {
display: flex;
flex-direction: column;
}
.col div {
width: 48px;
text-align: right;
margin: 0;
padding: 0;
color: #999;
}
.col div.prime {
font-weight: bolder;
color: #f33;
}
</style>
</head>
<body>
<div class="cols"></div>
<script src="./primes.js"></script>
<script>
const COLS = document.getElementsByClassName('cols')[0];
let COL = document.createElement("div");
const ODDS = [];
COL.className = "col";
for (let i = 1; i < 10000; i += 1) {
ODDS.push(i);
}
for (let i = 0; i < ODDS.length; i++) {
let div = document.createElement("div");
div.textContent = ODDS[i];
if (PRIMES.has(ODDS[i])) {
div.className = "prime";
}
COL.appendChild(div);
}
const paint = idx => {
let LAST_CHILD = COLS.lastChild.childNodes;
let CP = document.createElement("div");
CP.className = "col";
for (let i = 0; i < LAST_CHILD.length; i += 2) {
CP.appendChild(LAST_CHILD[i].cloneNode(true));
}
// debugger
COLS.appendChild(CP);
}
COLS.appendChild(COL);
for (let i = 1; i < 16; i++) {
paint(i);
}
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。