Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
OnTheFlyPrimeTable Class Reference

#include <prime_tables.h>

Inheritance diagram for OnTheFlyPrimeTable:
Collaboration diagram for OnTheFlyPrimeTable:

Public Member Functions

virtual bool IsPrime (int n) const
 
virtual int GetNextPrime (int p) const
 
- Public Member Functions inherited from PrimeTable
virtual ~PrimeTable ()
 

Detailed Description

Definition at line 56 of file prime_tables.h.

Member Function Documentation

◆ GetNextPrime()

virtual int OnTheFlyPrimeTable::GetNextPrime ( int p) const
inlinevirtual

Implements PrimeTable.

Definition at line 69 of file prime_tables.h.

69 {
70 for (int n = p + 1; n > 0; n++) {
71 if (IsPrime(n)) return n;
72 }
73
74 return -1;
75 }
const mie::Vuint & p
Definition bn.cpp:27
virtual bool IsPrime(int n) const
Here is the call graph for this function:

◆ IsPrime()

virtual bool OnTheFlyPrimeTable::IsPrime ( int n) const
inlinevirtual

Implements PrimeTable.

Definition at line 58 of file prime_tables.h.

58 {
59 if (n <= 1) return false;
60
61 for (int i = 2; i*i <= n; i++) {
62 // n is divisible by an integer other than 1 and itself.
63 if ((n % i) == 0) return false;
64 }
65
66 return true;
67 }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: