TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Calculate The Given Number Is Prime Number Or Not Using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
620
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssva30.rar
// prime or not
import
java.io.*;
class
ssva30
{
public
static
void
main(String arg[])
throws
IOException
{
int
n,i,p=
1
;
BufferedReader inp =
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.print(
"\n\t\t\tChecking the Number is prime or Not"
);
System.out.println(
"\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
);
System.out.print(
"\nEnter the Value of N: "
);
n=Integer.parseInt(inp.readLine());
for
(i=
2
;i<n;i++)
{
if
(n%i==
0
)
p=
0
;
}
if
(p==
0
)
System.out.print(
"\nThis is not Prime Number\n"
);
else
System.out.print(
"\nThis is Prime Number\n"
);
}
}
Java