primes.cpp 368 B

1234567891011121314151617181920
  1. #include "primes.h"
  2. #include <util/generic/array_size.h>
  3. #include <util/generic/algorithm.h>
  4. namespace NKikimr {
  5. static const unsigned long PRIMES[] = {
  6. #include "primes.gen"
  7. };
  8. unsigned long FindNearestPrime(unsigned long num) {
  9. if (num <= *PRIMES) {
  10. return *PRIMES;
  11. }
  12. return *LowerBound(PRIMES, PRIMES + Y_ARRAY_SIZE(PRIMES) - 1, num);
  13. }
  14. }