Git Product home page Git Product logo

pisearch's Introduction

PiSearch

A program that finds the positions of a number pattern in the given decimals of Pi.

The script is a Python program that searches for a number pattern in the decimals of Pi with a given precision. The program first imports the mpmath library, which is a Python library for high-precision mathematics.

The program then defines a function called search_pi_all(), which takes two arguments: the pattern to search for and the desired precision of Pi. The function first sets the precision of Pi using the mp.dps function. Then, it gets the string representation of Pi with the desired precision using the str() function.

The function then initializes a list to store the positions where the pattern is found. It starts by finding the first occurrence of the pattern in the string representation of Pi using the find() function. If the pattern is found, the function appends the index of the occurrence to the list of positions. Then, it starts the next search after the previously found position.

The function continues searching for the pattern until it cannot find it anymore. It then returns the list of positions where the pattern was found.

The main function of the program first asks the user to enter the number pattern they want to search for in Pi. Then, it calls the search_pi_all() function with the number pattern and the desired precision (25000 decimal places).

If the pattern is found, the function prints the positions where the pattern was found and the total number of times it was found. Otherwise, the function prints a message saying that the pattern was not found.

Here is an Example Output for pattern 420 in the PiDecimals:

image

pisearch's People

Contributors

mrraja23 avatar

Stargazers

 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.