MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / isPrime

Function isPrime

src/backend/common/dispatch.hpp:25–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23// itk::Math::{IsPrimt, GreatestPrimeFactor}
24template<typename T>
25inline bool isPrime(T n) {
26 if (n <= 1) return false;
27
28 const T last{(T)std::sqrt((double)n)};
29 for (T x{2}; x <= last; ++x) {
30 if (n % x == 0) return false;
31 }
32
33 return true;
34}
35
36template<typename T>
37inline T greatestPrimeFactor(T n) {

Callers 1

greatestPrimeFactorFunction · 0.85

Calls 1

sqrtFunction · 0.85

Tested by

no test coverage detected