Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Calculate The Given Number Is Prime Number Or Not Using Java
WhatsApp
Senthilvelan Sambamoorthy
Aug 13
2016
669
0
0
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
Up Next
Calculate The Given Number Is Prime Number Or Not Using Java