MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / next_prime

Function next_prime

data_structures/hashing/number_theory/prime_numbers.py:50–59  ·  view source on GitHub ↗
(value, factor=1, **kwargs)

Source from the content-addressed store, hash-verified

48
49
50def next_prime(value, factor=1, **kwargs):
51 value = factor * value
52 first_value_val = value
53
54 while not is_prime(value):
55 value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1
56
57 if value == first_value_val:
58 return next_prime(value + 1, **kwargs)
59 return value

Callers 2

rehashingMethod · 0.85
__hash_function_2Method · 0.85

Calls 1

is_primeFunction · 0.70

Tested by

no test coverage detected