File: prime.cpp

package info (click to toggle)
yrmcds 1.1.9-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 940 kB
  • sloc: cpp: 11,149; sh: 148; makefile: 117
file content (37 lines) | stat: -rw-r--r-- 601 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cybozu/hash_map.hpp>
#include <cybozu/test.hpp>

#include <map>

const std::map<unsigned int, unsigned int> ANS = {
    {0, 1},
    {1, 1},
    {2, 2},
    {3, 3},
    {4, 5},
    {5, 5},
    {6, 7},
    {7, 7},
    {8, 11},
    {9, 11},
    {10, 11},
    {11, 11},
    {12, 13},
    {13, 13},
    {14, 17},
    {15, 17},
    {16, 17},
    {17, 17},
    {18, 19},
    {19, 19},
    {20, 23},
    {1024, 1031},
    {2097152, 2097169},
    {2147483648, 2147483659}
};

AUTOTEST(prime) {
    for( auto& kv: ANS ) {
        cybozu_assert( cybozu::nearest_prime(kv.first) == kv.second );
    }
}