DEV Community

Amit Prajapati
Amit Prajapati

Posted on

Write a program to print prime numbers from 1 to 50

for(let i=2;i<=50;i++){  
    for(let j=2;j<=i;j++){
        let reminder = i%j;
        if(i != j){
         if(!reminder) break;
        }        
        if(j==i){
          console.log( i, ' is prime number')     
        }     
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)