Skip to content

Commit

Permalink
Update PrimeNumbers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kouhei-1 authored Nov 11, 2024
1 parent fcd009f commit 98df827
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions limited/PrimeNumbers.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
/*
function isPrime(num) {
// 素数判定関数
for(let i = 2, sqrt = Math.sqrt(num); i <= sqrt; i++)
if(num % i === 0) return false;
return num > 1;
}
function generatePrimeNumbers() {
const upperLimit = document.getElementById('upperLimit').value;
let primeNumbers = [];
for (let i = 2; i <= upperLimit; i++) {
if (isPrime(i)) {
primeNumbers.push(i);
}
}
}
*/
function generatePrimeNumbers() {
//以下区切り値
const delimiter_select=document.getElementById("delimiter").value
if(delimiter_select == "enter"){
const delimiter_txt="\n"
}else{
const delimiter_txt=","
// 区切り文字を設定
const delimiter_select = document.getElementById("delimiter").value;
let delimiter_txt;
if (delimiter_select === "enter") {
delimiter_txt = "\n";
} else {
delimiter_txt = ",";
}

const upperLimit = parseInt(document.getElementById('upperLimit').value);
Expand All @@ -44,11 +26,13 @@ function generatePrimeNumbers() {
primeNumbers.push(i);
}
}

// CSV形式に変換
const csvContent = primeNumbers.join(delimiter_txt);

// ダウンロードリンクの作成
const downloadLink = document.createElement('a');
downloadLink.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csvContent);
downloadLink.download='primeNumbers.csv'
downloadLink.download = 'primeNumbers.csv';
downloadLink.click();
}

0 comments on commit 98df827

Please sign in to comment.