Sunday, September 4, 2016

Program to print prime numbers in java



package com.instaceofjava;
public class primenumbers {

public static void main(String[] args) {

int num=50;
int count=0;

for(int i=2;i<=num;i++){

count=0;

for(int j=2;j<=i/2;j++){

if(i%j==0){
count++;
break;
}

}

if(count==0){

System.out.println(i);

}


}

Bhanu Namikaze

Author & Editor

Bhanu Namikaze is an Ethical Hacker, Passionate Blogger, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors, Surfing and Social Networking. Feel Free To Contact Me @ Bhanu.

0 comments:

Post a Comment

Popular Posts

Copyrights @ Interview Questions.Me - Blogger Templates Designed by Templateism - Distributed By Protemplateslab

  • (91) 5544 654942
  • Bhanu@HackingDream.net
  • Interview Questions

Copyrights @ Interview Questions.Me -A Site By Bhanu In Association With Hacking Dream