proxygen
OnTheFlyPrimeTable Class Reference

#include <prime_tables.h>

Inheritance diagram for OnTheFlyPrimeTable:
PrimeTable PrimeTable PrimeTable

Public Member Functions

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

Detailed Description

Definition at line 56 of file prime_tables.h.

Member Function Documentation

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

Implements PrimeTable.

Definition at line 69 of file prime_tables.h.

References PrimeTable::IsPrime().

69  {
70  for (int n = p + 1; n > 0; n++) {
71  if (IsPrime(n)) return n;
72  }
73 
74  return -1;
75  }
virtual bool IsPrime(int n) const
Definition: prime_tables.h:58
virtual int OnTheFlyPrimeTable::GetNextPrime ( int  p) const
inlinevirtual

Implements PrimeTable.

Definition at line 69 of file prime_tables.h.

References PrimeTable::IsPrime().

69  {
70  for (int n = p + 1; n > 0; n++) {
71  if (IsPrime(n)) return n;
72  }
73 
74  return -1;
75  }
virtual bool IsPrime(int n) const
Definition: prime_tables.h:58
virtual int OnTheFlyPrimeTable::GetNextPrime ( int  p) const
inlinevirtual

Implements PrimeTable.

Definition at line 69 of file prime_tables.h.

References PrimeTable::IsPrime().

69  {
70  for (int n = p + 1; n > 0; n++) {
71  if (IsPrime(n)) return n;
72  }
73 
74  return -1;
75  }
virtual bool IsPrime(int n) const
Definition: prime_tables.h:58
virtual bool OnTheFlyPrimeTable::IsPrime ( int  n) const
inlinevirtual

Implements PrimeTable.

Definition at line 58 of file prime_tables.h.

References i.

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  }
virtual bool OnTheFlyPrimeTable::IsPrime ( int  n) const
inlinevirtual

Implements PrimeTable.

Definition at line 58 of file prime_tables.h.

References i.

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  }
virtual bool OnTheFlyPrimeTable::IsPrime ( int  n) const
inlinevirtual

Implements PrimeTable.

Definition at line 58 of file prime_tables.h.

References i.

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  }

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