• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Jira Selenium Protractor Testing SDLC Agile Methodology

Java Selenium Tutorial & Testing Interview Questions

  • Home
  • Interview Questions
  • Java
  • Java Programs
  • Test Cases
  • Selenium
  • Manual Testing
  • Difference
  • Search
SoftwareTestingo » Java Programs » Write a Program to Find Out Prime Number Java Example Program?

Write a Program to Find Out Prime Number Java Example Program?

Last Updated on: April 24, 2019 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • Check Also: ReferEnce Variable Java Example

Prime Number Java Program: A prime number is a natural number, which is greater than 1 and that has no positive divisions other than 1 and itself.

Example: 1,2,3,5,7,11,13… etc

package com.java.Softwaretestingblog;
public class Primeno {

   public static void main(String[] args) {
      // TODO Auto-generated method stub
      int i,k,j;
      for(i=1;i<100;i++)
      {
         k= 0;
         for(j=2;j<i;j++)
         {
            if(i%j== 0)
            {
               k=1;
               break;
            }
         }
         if(k==0)
         {
            System.out.println(i);
         }
      }
   }
}

 

Execution: If the above image is not visible clearly then you can use this link

Check Also: ReferEnce Variable Java Example

Output:

1
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97

 

    Filed Under: Java Programs Tagged With: Common Java Interview Programs, Java Interview Programs, Java Programs

    Reader Interactions

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Tutorials Important Links

    • Software Testing Jobs
    • Manual Testing Tutorial
    • Selenium Tutorial
    • Core Java Tutorial
    • TestNG Tutorial
    • Java Programs
    • Selenium Programs
    • Manual Test Cases
    • Interview Tips
    • Contact US
    • www.softwaretestingo.com

    Important Links

    • Software Testing Interview Questions
    • Agile Interview Questions
    • Manual Testing Interview Questions
    • Testing Interview Questions
    • Selenium Interview Questions
    • Selenium Real Time Interview Questions
    • Selenium WebDriver Interview Questions
    • Automation Framework Interview Questions
    • Appium Interview Questions
    • TestNG Interview Questions
    • Java Interview Questions
    • Core Java Interview Questions

    Categories

    Copyright © 2021 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy