Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
e7734fb8
Commit
e7734fb8
authored
Jan 02, 2018
by
misterg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OSS Sync, cl 163329677
parent
1c2f1907
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
prime_tables.h
googletest/samples/prime_tables.h
+6
-2
No files found.
googletest/samples/prime_tables.h
View file @
e7734fb8
...
...
@@ -103,11 +103,15 @@ class PreCalculatedPrimeTable : public PrimeTable {
::
std
::
fill
(
is_prime_
,
is_prime_
+
is_prime_size_
,
true
);
is_prime_
[
0
]
=
is_prime_
[
1
]
=
false
;
for
(
int
i
=
2
;
i
<=
max
;
i
++
)
{
// Checks every candidate for prime number (we know that 2 is the only even
// prime).
for
(
int
i
=
2
;
i
*
i
<=
max
;
i
+=
i
%
2
+
1
)
{
if
(
!
is_prime_
[
i
])
continue
;
// Marks all multiples of i (except i itself) as non-prime.
for
(
int
j
=
2
*
i
;
j
<=
max
;
j
+=
i
)
{
// We are starting here from i-th multiplier, because all smaller
// complex numbers were already marked.
for
(
int
j
=
i
*
i
;
j
<=
max
;
j
+=
i
)
{
is_prime_
[
j
]
=
false
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment