<!DOCTYPE html>
<html>
<head>
<title>素数カウント</title>
</head>
<body>
<h1>素数カウント</h1>
<p id="count"></p>
<p id="text"></p>
<p id="history"></p>
<button onclick="countPrime()">落ち着くんだ…素数を数えて落ち着くんだ…</button>
<script>
let count = 0;
let history = [];
function isPrime(num) {
if (num < 2) {
return false;
}
for (let i = 2; i < num; i++) {
if (num % i === 0) {
return false;
}
}
return true;
}
function getRandomText() {
const texts = [
'カブト虫',
'イチジクのタルト',
'ジョット',
'ドロローサへの道',
'秘密の皇帝',
'らせん階段',
'廃墟の街',
'特異点',
'紫陽花',
'天使(エンジェル)'
];
return texts[Math.floor(Math.random() * texts.length)];
}
function countPrime() {
count++;
if (isPrime(count)) {
const text = getRandomText();
history.push(text);
document.getElementById('count').textContent = count;
document.getElementById('text').textContent = text;
document.getElementById('history').textContent = history.join(', ');
if (history.length === 14) {
setTimeout(function() {
document.body.style.backgroundColor = 'purple';
document.getElementById('text').textContent = '感じたぞッ!『位置』が来るッ!';
setTimeout(function() {
document.getElementById('text').textContent = 'メイド・イン・ヘヴン!!!';
document.body.style.animation = 'scroll 20s linear';
setTimeout(function() {
document.getElementById('text').textContent = '';
document.body.style.animation = '';
document.body.style.backgroundColor = '';
count = 0;
history = [];
document.getElementById('count').textContent = '';
document.getElementById('text').textContent = '';
document.getElementById('history').textContent = '';
}, 20000);
}, 1000);
}, 5000);
}
}
else {
document.getElementById('count').textContent = count;
document.getElementById('text').textContent = '';
}
}
</script>
</body>
</html>