https://github.com/vincenttam/catalannum
Comparison of time needed for evaluating Catalan number
https://github.com/vincenttam/catalannum
Last synced: about 2 months ago
JSON representation
Comparison of time needed for evaluating Catalan number
- Host: GitHub
- URL: https://github.com/vincenttam/catalannum
- Owner: VincentTam
- License: gpl-3.0
- Created: 2018-01-30T21:19:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-30T22:14:13.000Z (over 7 years ago)
- Last Synced: 2025-02-15T22:43:15.911Z (3 months ago)
- Language: C
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Catalan number comparison
===Goal
---This project aims to compare the time elapsed for calculating the
Catalan number `C_n = (2n)!/(n! (n+1)!)`.Languages
---- C (with GNU MultiPrecision Library)
- `catlist`: List first `N` Catalan numbers. (Use `N ≤ 4000` to
avoid hanging your device.)
- `catalanNumber`: `N = 100000` has been successfully tested. Try
larger `N` at your risk.
- GNU Octave: copied from Rosetta code (Use `N ≤ 60` to avoid
precision lost)My results
---- C
- `catlist`: `N = 2000` takes 2 seconds.
- `catalanNumber`: `N = 100000` takes 3 seconds.
- GNU Octave: `N = 60` takes 0.6 second.Advantages and disadvantages:
---- C: runs (≥100×) faster, but more difficult to write
- GNU Octave: runs slower, but easier to writeConclusion: which one to use?
---- C: for *serious* performance reasons/arbitrary precision since the
time saved for one iteration is only about 3 seconds
- GNU Octave: for ordinary usageLicense
---[](https://www.gnu.org/licenses/gpl-3.0)