Git Product home page Git Product logo

prime's Introduction

Prime

A mini CUDA project used to test binary Goldbach conjecture on [a, b].

Introduction

Goldbach conjecture is a famous mathematical problem:

Every even number greater than 2 as the sum of two prime numbers.

Example

8 = 3 + 5
10 = 3 + 7
12 = 5 + 7
and so on

One method to verifying the Goldbach conjecture is to test every number in a specific interval [a,b] is the sum of two prime numbers.

Compile

Compile the non-cuda version

Using gtest:

g++ -std=c++17 -o gtest gtest.cc prime.cc -lgtest -lpthread
./gtest

Expected output

[==========] Running 4 tests from 4 test suites.
[----------] Global test environment set-up.
[----------] 1 test from Sievetest
[ RUN      ] Sievetest.integer
[       OK ] Sievetest.integer (7009 ms)
[----------] 1 test from Sievetest (7009 ms total)

[----------] 1 test from miillerTest
[ RUN      ] miillerTest.prime
[       OK ] miillerTest.prime (0 ms)
[----------] 1 test from miillerTest (0 ms total)

[----------] 1 test from primeTest
[ RUN      ] primeTest.prime
[       OK ] primeTest.prime (18 ms)
[----------] 1 test from primeTest (18 ms total)

[----------] 1 test from goldbach
[ RUN      ] goldbach.segment
k and i are: 12 917
Time to generate:  2212.5 ms
The results are correct
[       OK ] goldbach.segment (2212 ms)
[----------] 1 test from goldbach (2212 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 4 test suites ran. (9241 ms total)
[  PASSED  ] 4 tests.

Compile the cuda (parallel) version

nvcc -o prime prime.cu
./prime

TODO

Convert int64 to string for bigger numbers.

Reference

[1]: Deshouillers, J-M., Herman JJ te Riele, and Yannick Saouter. "New experimental results concerning the Goldbach conjecture." International Algorithmic Number Theory Symposium. Springer, Berlin, Heidelberg, 1998.

prime's People

Contributors

morikka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.