1.What is prime number:
image:
can be over 100
2.This is my solution:
// find prime number blow var number
var number = 100
//show full or just prime number
var show = false
///////////////////////////////////////////////////////////////
var publicA
function module (a,b){
let i = 1
let j = 0
while (i < Math.round(a/2)) {
i += 1
if (a-(i*b) == 0) {
j += 1
}
}
if (j > 0){
publicA = 0
}else{
publicA = 1
}
}
function ChekPrime (n){
let i = 1
let j = 0
while (i <= Math.round(n/2)) {
i += 1
module(n,i)
if (publicA == 0) {
j += 1
}
}
if (j > 0){
if (show !== false){
console.log( n,“Is not prime number”)
}
}else{
if (show ==false){
console.log(n)
}else{
console.log( n,“Is prime number”)
}
}
}
while(2<number){
number -= 1
ChekPrime(number)
}
//Can replace while (){} to Time.schedule & if (){}
image:
output will be like this: