PHPackages                             josantonius/algorithm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. josantonius/algorithm

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

josantonius/algorithm
=====================

Class with algorithms to solve and display mathematical sequences.

1.1.7(4y ago)3212MITPHPPHP ^5.6 || ^7.0

Since Jan 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/josantonius/php-algorithm)[ Packagist](https://packagist.org/packages/josantonius/algorithm)[ GitHub Sponsors](https://github.com/Josantonius)[ RSS](/packages/josantonius-algorithm/feed)WikiDiscussions master Synced yesterday

READMEChangelog (9)Dependencies (4)Versions (10)Used By (0)

PHP Algorithm class
===================

[](#php-algorithm-class)

[![Latest Stable Version](https://camo.githubusercontent.com/b9abdcc66dac012db7754b5dbdc5a72e4bef3716f1d00f2b5716f7066af192e0/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f416c676f726974686d2f762f737461626c65)](https://packagist.org/packages/josantonius/algorithm)[![License](https://camo.githubusercontent.com/c027d6255f8003c094b952f0fff3050f18936984c2784aea73b84624833f7a4e/68747470733a2f2f706f7365722e707567782e6f72672f6a6f73616e746f6e6975732f616c676f726974686d2f6c6963656e7365)](LICENSE)[![PSR2](https://camo.githubusercontent.com/063e098f45d7eabe8d836eba9916e7c737801284e77189300e891b3085864d91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d322d3161626339632e737667)](http://www.php-fig.org/psr/psr-2/)[![PSR4](https://camo.githubusercontent.com/d1c090de87e968254a6658528f3bfe9c9dad422d6047fd1323dc211560182c01/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d342d3962353962362e737667)](http://www.php-fig.org/psr/psr-4/)[![CodeCov](https://camo.githubusercontent.com/4b155151b73788e9a88a5a67063b34c0342ee7d6ed38e5b838186b27fddf1025/68747470733a2f2f636f6465636f762e696f2f67682f6a6f73616e746f6e6975732f7068702d616c676f726974686d2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/josantonius/php-algorithm)

**Translations**: [Español](.github/lang/es-ES/README.md)

Class with algorithms to solve and display mathematical sequences.

---

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Methods](#available-methods)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Tests](#tests)
- [Changelog](#changelog)
- [Contribution](#contribution)
- [Sponsor](#sponsor)
- [License](#license)

---

Requirements
------------

[](#requirements)

This class is supported by **PHP versions 5.6** or higher and is compatible with **HHVM versions 3.0** or higher...

Installation
------------

[](#installation)

The preferred way to install this extension is through [Composer](http://getcomposer.org/download/).

To install **PHP Algorithm class**, simply:

```
composer require josantonius/algorithm
```

The previous command will only install the necessary files, if you prefer to **download the entire source code** you can use:

```
composer require josantonius/algorithm --prefer-source
```

You can also **clone the complete repository** with Git:

```
git clone https://github.com/josantonius/php-algorithm.git
```

Or **install it manually**:

[Download Algorithm.php](https://raw.githubusercontent.com/josantonius/php-algorithm/master/src/Algorithm.php):

```
wget https://raw.githubusercontent.com/josantonius/php-algorithm/master/src/Algorithm.php
```

Available Methods
-----------------

[](#available-methods)

Available methods in this class:

### Print "Look-and-Say" sequence

[](#print-look-and-say-sequence)

```
Algorithm::lookAndSay($lastSequence, $maxLines);
```

AttributeDescriptionTypeRequiredDefault$lastSequenceInitial value to start the sequenceintNo1$maxLinesMaximum lines number to showintNo15**\# Return** (string) → Sequence.

Quick Start
-----------

[](#quick-start)

To use this class with **Composer**:

```
require __DIR__ . '/vendor/autoload.php';

use Josantonius\Algorithm\Algorithm;
```

Or If you installed it **manually**, use it:

```
require_once __DIR__ . '/Algorithm.php';

use Josantonius\Algorithm\Algorithm;
```

Usage
-----

[](#usage)

Example of use for this class:

```
echo Algorithm::lookAndSay();

/*
1
11
21
1211
111221
312211
13112221
1113213211
31131211131221
13211311123113112211
11131221133112132113212221
3113112221232112111312211312113211
1321132132111213122112311311222113111221131221
11131221131211131231121113112221121321132132211331222113112211
311311222113111231131112132112311321322112111312211312111322212311322113212221
*/
```

```
echo Algorithm::lookAndSay(22, 5);

/*
22
22
22
22
22
*/
```

Tests
-----

[](#tests)

To run [tests](tests) you just need [composer](http://getcomposer.org/download/) and to execute the following:

```
git clone https://github.com/josantonius/php-algorithm.git
```

```
cd php-algorithm
```

```
composer install
```

Run unit tests with [PHPUnit](https://phpunit.de/):

```
composer phpunit
```

Run [PSR2](http://www.php-fig.org/psr/psr-2/) code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):

```
composer phpcs
```

Run [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:

```
composer phpmd
```

Run all previous tests:

```
composer tests
```

Changelog
---------

[](#changelog)

Detailed changes for each release are documented in the [release notes](https://github.com/josantonius/php-algorithm/releases).

Contribution
------------

[](#contribution)

Please make sure to read the [Contributing Guide](.github/CONTRIBUTING.md), before making a [pull request](.github/CONTRIBUTING.md#pull-requests), start a [discussion](.github/CONTRIBUTING.md#discussions) or report a [issue](.github/CONTRIBUTING.md#issues).

Thanks to all [contributors](https://github.com/josantonius/php-algorithm/graphs/contributors) to this project! ❤️

Sponsor
-------

[](#sponsor)

If you found this interesting, [you can become my sponsor!](https://github.com/josantonius#sponsor) 😊

License
-------

[](#license)

This project is licensed under the [MIT License](LICENSE).

Copyright © 2017-2022, [Josantonius](https://github.com/josantonius#contact)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~243 days

Recently: every ~430 days

Total

9

Last Release

1490d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.0

1.1.0PHP &gt;=5.6

1.1.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b221283501ec8a9cbaefaf27821a91ae8ddd33bddf1fccc6c6815b7ad216ff1?d=identicon)[Josantonius](/maintainers/Josantonius)

---

Top Contributors

[![josantonius](https://avatars.githubusercontent.com/u/18104336?v=4)](https://github.com/josantonius "josantonius (156 commits)")

---

Tags

algorithmlookandsayphp-algorithm-libraryphphhvmalgorithmsMathematical sequencesLook-and-SayConway constant

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/josantonius-algorithm/health.svg)

```
[![Health](https://phpackages.com/badges/josantonius-algorithm/health.svg)](https://phpackages.com/packages/josantonius-algorithm)
```

###  Alternatives

[nepster-web/gambling-tech

Gambling Algorithms for Certification.

122.0k](/packages/nepster-web-gambling-tech)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
