zero-indexed-ulam-spiral

0.0.1 • Public • Published

zero-indexed-ulam-spiral

This JavaScript library provides two functions for operating with the values of a zero-indexed Ulam Spiral:

import getLatticeCoordinatesFor from 'zero-indexed-ulam-spiral/getLatticeCoordinatesFor'
 
console.log(getLatticeCoordinatesFor(31))
// > [2, 3]
import getSpiralIndexForCoordinates from 'zero-indexed-ulam-spiral/getSpiralIndexForCoordinates'
 
console.log(getSpiralIndexForCoordinates([5, 6]))
// > 133

Why is this zero indexed?

Zero indexing is the most popular convention for indexes in programming. Either way, it’s really easy to transform.

What about primes?

This library is about operating with the pairing function from the lattice to the spiral and back. If you want to plot primes on top of it, it should be simple enough.

And yes, the diagonal stripe prime patterns always appear, no matter what the starting value is :)

Installation

yarn add zero-indexed-ulam-spiral

License

MIT

Package Sidebar

Install

npm i zero-indexed-ulam-spiral

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

39.4 kB

Total Files

9

Last publish

Collaborators

  • xaviervia