Skip to content

Commit

Permalink
To find prime number in array
Browse files Browse the repository at this point in the history
Given an array to find the prime number in it
  • Loading branch information
Arunkumar1712 authored Jan 4, 2024
1 parent fb26757 commit 0d801ce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions primenumber in array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//prime number in array
var arr = [1,2,3,4,5,6,7,8,9,10,11];
for(var i=0;i<arr.length;i++){
var count=0;
for(var j=1;j<i;j++){
if(arr[i]%j===0){
count++;
}
}
if(count===1){
console.log(arr[i]);
}
}

0 comments on commit 0d801ce

Please sign in to comment.