Giter Club home page Giter Club logo

primeunitdistribution's Introduction

Prime Unit Digit Distribution

A program to calculate the unit digit distribution of prime number up to a given limit

Compilation and Usage

  1. Clone the repository $ git clone https://github.com/tanveerraza789/PrimeUnitDistribution.git
  2. Open the cloned directory $ cd PrimeunitDistribution
  3. Change LIMIT according to usage
  4. Compile using GCC $ g++ -g main.cpp -o main
  5. Run $ ./main

Algorithm

In this program, the Sieve of Eratosthenes algorithm is used to find all prime number between 0 and LIMIT which runs in O(n) space complexity and O(n log log n) time complexity (provided the array update is an O(1) operation, as is usually the case).

Results

Limit = 9999999
Digit  : Digit Count : Percentage
-------------------------------
0      : 0           :    0.00%
1      : 166104      :   24.99%
2      : 1           :    0.00%
3      : 166230      :   25.01%
4      : 0           :    0.00%
5      : 1           :    0.00%
6      : 0           :    0.00%
7      : 166211      :   25.01%
8      : 0           :    0.00%
9      : 166032      :   24.98%
Time taken : 1.55s  

Pie chart representing data

Conclusion

From the distribution table it is clear that mostly all the prime number have either 1,3,7, and 9 as unit digit

If the LIMIT tends to infinity, each distribution will tends to become 25%

primeunitdistribution's People

Contributors

atamakahere-git avatar

Stargazers

 avatar  avatar  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.