-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (29 loc) · 895 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const express =require('express');
const app = express();
let port = 3000;
var os = require("os");
var hostname = os.hostname();
app.get('/', function (req,res){
/* n의 소수찾기*/
const n = 100000;
let nums = [...Array(n).keys()];
for(let i =2; i*i < n; i++){
if(nums[i] !== 0){
for(let j = i*i; j<n; j+=i){
nums[j] = 0;
}
}
}
let getPrimes = [];
for(let i=0; i<nums.length; i++){
if(nums[i] > 1){
getPrimes.push(nums[i]);
}
}
// console.log("### getPrimes => " ,getPrimes.toString())
console.log("### getPrimes.length => " ,getPrimes.length)
res.send('<br> 호스트정보 : '+ hostname + '<br><br> 100,000의 소수 개수는 : '+getPrimes.length)
});
app.listen(port, function (){
console.log('서버가 시작되었습니다. 포트:%s',port);
});