Guest User

Untitled

a guest
Oct 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. public class asd
  2. {
  3. public static boolean IsPrime(int n)
  4. {
  5. if(n == 2) return true;
  6. int i = 2;
  7. while(i<n)
  8. {
  9. if(n%i==0) return false;
  10. i++;
  11. }
  12. return true;
  13. }
  14. public static int next(int n)
  15. {
  16. int x = n+1;
  17. while(true)
  18. {
  19. if (IsPrime(x))
  20. {
  21. return x;
  22. }
  23. else
  24. {
  25. x++;
  26. }
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment