fork download
  1. #include <bits/stdc++.h>
  2. #define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  3. using namespace std;
  4. typedef unsigned long long ull;
  5. int t;
  6. ull n;
  7. bool isPrime(const ull &num)
  8. {
  9. if (num <= 1)
  10. return false;
  11. if (num <= 3)
  12. return true;
  13. if (num % 2 == 0 || num % 3 == 0)
  14. return false;
  15. for (int i = 2; i < sqrt(num); ++i)
  16. {
  17. if (num % i == 0)
  18. return false;
  19. }
  20. return true;
  21. }
  22. int main()
  23. {
  24. fastio;
  25. cin >> t;
  26. for (int i = 0; i < t; ++i)
  27. {
  28. cin >> n;
  29. while (!isPrime(n))
  30. ++n;
  31. cout << n << '\n';
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5272KB
stdin
1
25
stdout
25