- 注册时间
- 2021-7-10
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 1509
- 在线时间
- 小时
|
楼主 |
发表于 2021-10-22 09:04:15
|
显示全部楼层
問題已解決
本帖最后由 ejsoon 于 2021-10-22 15:56 编辑
寡人自己寫了個html+js,拿到了十萬以內的素數。感謝各位,寡人覺的應該已經夠用了。
附html+js代碼:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>search prime number</title>
- <style>
- .txtaa {
- width: 90%;
- }
- .cal_btn {
- font-size: 24pt;
- }
- </style>
- </head>
- <body>
- <button class="cal_btn" onclick="cal_prime()">GO!</button>
- <h2 class="coltitle col1">1~9</h2>
- <div class="col1 status">End, account are 4.</div>
- <textarea class="txtaa tta1">2, 3, 5, 7</textarea>
- <h2 class="coltitle col2">10~99</h2>
- <div class="col2 status">waiting...</div>
- <textarea class="txtaa tta2"></textarea>
- <h2 class="coltitle col3">100~999</h2>
- <div class="col3 status">waiting...</div>
- <textarea class="txtaa tta3"></textarea>
- <h2 class="coltitle col4">1000~9999</h2>
- <div class="col4 status">waiting...</div>
- <textarea class="txtaa tta4"></textarea>
- <h2 class="coltitle col5">10000~99999</h2>
- <div class="col5 status">waiting...</div>
- <textarea class="txtaa tta5"></textarea>
- <script>
- function cal_prime () {
- var prime_array = [2, 3, 5, 7]; // prime_number
- var prime_point = 10; // prime_number point
- var prime_count = 0; // prime_number aacount
- while (prime_point < 99999) { // 10
- for (var j = 0; j < prime_array.length && prime_point / 2 >= prime_array[j]; j++) { // 2, 3, [5], 7
- if (Number.isInteger(prime_point / prime_array[j])) {
- break;
- }
- }
- if (j == prime_array.length || prime_point / 2 < prime_array[j]) {
- prime_array.push(prime_point);
- prime_count++;
- if (prime_point < 99) {
- document.querySelector(".tta2").value += prime_point + ', ';
- } else if (prime_point < 999) {
- document.querySelector(".tta3").value += prime_point + ', ';
- } else if (prime_point < 9999) {
- document.querySelector(".tta4").value += prime_point + ', ';
- } else if (prime_point < 99999) {
- document.querySelector(".tta5").value += prime_point + ', ';
- }
- }
- prime_point++;
- if (99 == prime_point) {
- document.querySelector(".col2.status").innerHTML = "End, account are " + prime_count + ".";
- prime_count = 0;
- } else if (999 == prime_point) {
- document.querySelector(".col3.status").innerHTML = "End, account are " + prime_count + ".";
- prime_count = 0;
- } else if (9999 == prime_point) {
- document.querySelector(".col4.status").innerHTML = "End, account are " + prime_count + ".";
- prime_count = 0;
- } else if (99999 == prime_point) {
- document.querySelector(".col5.status").innerHTML = "End, account are " + prime_count + ".";
- prime_count = 0;
- }
- }
- }
- </script>
- </body>
- </html>
复制代码 |
|