File: previous_prime.cpp

package info (click to toggle)
primesieve 5.7.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,064 kB
  • ctags: 1,079
  • sloc: cpp: 5,871; makefile: 232; ansic: 176; sh: 102
file content (18 lines) | stat: -rw-r--r-- 395 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// @example previous_prime.cpp
/// Iterate backwards over primes using primesieve::iterator.

#include <primesieve.hpp>
#include <iostream>

int main()
{
  primesieve::iterator it;
  it.skipto(2000);
  uint64_t prime = it.previous_prime();

  // iterate over the primes from 2000 to 1000
  for (; prime >= 1000;  prime = it.previous_prime())
    std::cout << prime << std::endl;

  return 0;
}