The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
PrimeNumber.java
By Guest on 14th August 2019 09:51:32 AM | Syntax: TEXT | Views: 0



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. package series;
  2. public class PrimeNumber
  3. {
  4. int no;
  5. public Number(int n)
  6. {
  7. int status=1;
  8. int num=3;
  9. if(n>=1)
  10. {
  11. System.out.println("First"+n+"Prime numbers are.....\n");
  12. System.out.println(2);
  13. }
  14.  
  15. for(int i=1;i<=n;)
  16. {
  17. for(int j=1;j<=Math.sqrt(num);j++)
  18. {
  19. if(num%j==0)
  20. {
  21. status=0;
  22. break;
  23. }
  24. }
  25.  
  26. if(status!=0)
  27. {
  28. System.out.println(num);
  29. i++;
  30. }
  31.  
  32. status=1;
  33. num++;
  34. }
  35.  
  36. }
  37. }



  • Recent Pastes