Giter Site home page Giter Site logo

pascal's Introduction

README.md

Author: Aaron Stone

Repository Overview

This repository contains a program to study a Pascal's triangle, specifically the center "column" (also known as the central binomial coefficients). For example, the first 15 rows of Pascal's triangle are as follows:

                                              1
                                           1     1
                                        1     2     1
                                     1     3     3     1
                                  1     4     6     4     1
                               1     5    10    10     5     1
                            1     6    15    20    15     6     1
                         1     7    21    35    35    21     7     1
                      1     8    28    56    70    56    28     8     1
                   1     9    36    84   126   126    84    36     9     1
                1    10    45   120   210   252   210   120    45    10     1
             1    11    55   165   330   462   462   330   165    55    11     1
          1    12    66   220   495   792   924   792   495   220    66    12     1
       1    13    78   286   715  1287  1716  1716  1287   715   286    78    13     1
    1    14    91   364  1001  2002  3003  3432  3003  2002  1001   364    91    14     1

So, the center column of this triangle is:

[1, 2, 6, 20, 70, 252, 924, 3432]

From this sequence, I have defined a new sequence as follows:

1. Take the digital root of each element:

[1, 2, 6, 2, 7, 9, 6, 3]

2. Identify all 3's, 6's, and 9's in the sequence, and partition the sequence using these elements as the "cutting points":

[1, 2], [6], [2, 7], [9], [6], [3]

3. Sum the elements in each partition:

[3], [6], [9], [9], [6], [3]

4. Take the digital root of each sum, yielding the final sequence (this section of the sequence remains unchanged):

[3, 6, 9, 9, 6, 3]

Observations / Findings

After testing my initial, hand-written observations with thousands of additional, programmatically generated examples, the results seem to indicate that this sequence only yields 3's, 6's and 9's. Additionally, as the sequence increases in length, it seems to converge to repeating 9's. Further testing is required to confirm this, and the reason for this behavior is not entirely clear.

Files

generate.py

This file provides a terminal-based user interface for generating and displaying Pascal's triangles.

pascal.py

This file provides functions for generating and displaying Pascal's triangles. It includes:

  • A function to generate a Pascal's triangle of a given size.
  • A function to neatly print Pascal's triangles to the terminal.

study.py

This file contains the necessary functionality to study the sequence I have defined above.

Usage Instructions

To use the program to generate Pascal's triangles, simply run the generate.py file with Python:

python main.py

This will launch a user interface that allows you to generate Pascal's triangles. You will be prompted to enter the number of rows for the triangle, and the program will then generate and display the Pascal's triangle with the specified number of rows. After viewing the generated triangle, you can choose to generate a new triangle or exit the program by entering 'Y' (yes) or 'N' (no) when prompted.

To use the program to study the sequence I have defined above, simply run the study.py file with Python:

python study.py

This will generate and display the sequence for the first ROWS_TO_STUDY rows of Pascal's triangle. To adjust the number of rows you wish to study, simply modify this variable to your desired value. The default value is 100.

Example:

The first 175 rows of Pascal's triangle yields the following sequence:

[3, 6, 9, 9, 6, 3, 9, 6, 3, 9, 9, 9, 9, 9, 6, 3, 9, 3, 6, 9, 9, 9, 9, 6, 3, 9, 9, 3, 6, 9, 3, 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 3, 9, 3, 6, 9, 9, 9, 9, 3, 6, 9, 6, 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 6, 3, 9, 9, 3]

pascal's People

Contributors

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