Guest User

Untitled

a guest
Oct 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package javaapplication1;
  7. import java.io.*;
  8.  
  9. /**
  10. *
  11. * @author abi11322
  12. */
  13. public class PrimeNumber {
  14.  
  15. /**
  16. * @param args the command line arguments
  17. */
  18. public static void main(String[] args) throws Exception {
  19. // TODO code application logic here
  20. int i;
  21. BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  22.  
  23. System.out.println("Enter number: ");
  24. int num = Integer.parseInt(bf.readLine());
  25. System.out.println("Prime number: ");
  26.  
  27. for (i=1; i < num; i++ )
  28. {
  29. int j;
  30. for (j=2; j<i; j++)
  31. {
  32. int n = i%j;
  33. if(n==0)
  34. {
  35. break;
  36. }
  37.  
  38. }
  39. if(i == j)
  40. {
  41. System.out.print(" "+i);
  42. }
  43. }
  44.  
  45. }
  46.  
  47. }
Add Comment
Please, Sign In to add comment