Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict"
- console.log(maybePrime(20, 50))
- function isPrime(prm) {
- let countPrime = 0
- for (let j = 2; j <= Math.floor(Math.sqrt(prm)); j++) {
- if (prm % j == 0) {
- countPrime++
- }
- }
- if (countPrime == 0) {
- return true
- }
- else {
- return false
- }
- }
- function maybePrime(r1, r2) {
- let countPrime = 0
- let foundPrime = 0
- let arr = []
- for (let i = r1; i <= r2; i++) {
- let countPrime = 0
- for (let j = 2; j <= Math.floor(Math.sqrt(i)); j++) {
- if (i % j == 0) {
- countPrime++
- }
- }
- if (countPrime == 0) {
- //console.log(i)
- console.log(isPrime(i))
- foundPrime++
- arr.push(i)
- }
- if (foundPrime > 2) {
- break
- }
- }
- return arr
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement