Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- import java.io.*;
- /**
- *
- * @author abi11322
- */
- public class PrimeNumber {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws Exception {
- // TODO code application logic here
- int i;
- BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter number: ");
- int num = Integer.parseInt(bf.readLine());
- System.out.println("Prime number: ");
- for (i=1; i < num; i++ )
- {
- int j;
- for (j=2; j<i; j++)
- {
- int n = i%j;
- if(n==0)
- {
- break;
- }
- }
- if(i == j)
- {
- System.out.print(" "+i);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment