PHPackages                             szczyglis/php-ulam-spiral-generator - 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. szczyglis/php-ulam-spiral-generator

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

szczyglis/php-ulam-spiral-generator
===================================

A mathematical Ulam spiral generator and renderer with programmable callbacks written in PHP.

v1.2.3(1y ago)26MITPHPPHP ^7.2.5|^8.0

Since Apr 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/szczyglis-dev/php-ulam-spiral-generator)[ Packagist](https://packagist.org/packages/szczyglis/php-ulam-spiral-generator)[ Docs](https://github.com/szczyglis-dev/php-ulam-spiral-generator)[ RSS](/packages/szczyglis-php-ulam-spiral-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)DependenciesVersions (6)Used By (0)

Release: **1.2.3** | build: **2024.08.26** | PHP: **^7.2.5|^8.0**

Ulam Spiral Generator
=====================

[](#ulam-spiral-generator)

A mathematical Ulam spiral generator and renderer with programmable callbacks written in PHP.

Live Demo:
--------------------------------------------------------

[](#live-demo-httpsszczyglisdevulam-spiral-generator)

What is Ulam spiral?
--------------------

[](#what-is-ulam-spiral)

from [https://en.wikipedia.org/wiki/Ulam\_spiral](https://en.wikipedia.org/wiki/Ulam_spiral):

> The Ulam spiral or prime spiral is a graphical depiction of the set of prime numbers, devised by mathematician Stanisław Ulam in 1963 and popularized in Martin Gardner's Mathematical Games column in Scientific American a short time later. It is constructed by writing the positive integers in a square spiral and specially marking the prime numbers. \[...\]

[![300px-Ulam_1](https://user-images.githubusercontent.com/61396542/75210085-6d55ee80-5780-11ea-86fd-ab6bcabdab88.png)](https://user-images.githubusercontent.com/61396542/75210085-6d55ee80-5780-11ea-86fd-ab6bcabdab88.png)

How to install
--------------

[](#how-to-install)

```
composer require szczyglis/php-ulam-spiral-generator

```

Features
--------

[](#features)

- Ulam spiral matrix builder compatible with any dataset.
- Built-in on-screen spiral renderer (as an HTML table or raw data).
- Suitable for standalone and external usage (consists of a single PHP class).
- Programmable callbacks for highlighting and counting numbers in rows and columns.
- JavaScript-based real-time highlighter for rows, columns, and crosses.
- Easy to use.

Usage example
-------------

[](#usage-example)

```
