Skip to content

nuclear-bean/ulam-spiral

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

prime-spiral

'There is no apparent reason why one number is prime and another not.
On the contrary, upon looking at these numbers one has the feeling of being in the presence of one of the inexplicable secrets of creation.'

Overview

This is a tool for visualizing and exploring prime spirals. Ulam Spiral is currently the only supported variation.

Read more about Ulam Spiral

Usage

explore spiral/src/main/java/spirals/ulam/examples for examples on how to generate spirals.

Examples

Example classes can be found under ./spiral/src/main/java/spirals/ulam/examples. Currently, divided into 2 categories: basic and density. Basic examples simply calculate an Ulam's spiral and highlight or filter for a specific type of primes. Density examples calculate density of primes using different strategies. Each example class can be customized, just modify the static variables above main method and run the method itself. Output will be saved to an appropriate directory in ./output

List of example classes with description:

Basic
  • EB01_BasicUlam - generates simple Ulam's spiral of given size. Primes are black pixels, composites are white
  • EB02_TwinPrimes - marks only twin primes or highlights them in red amongst all primes
  • EB03_CousinPrimes - marks only cousin primes
  • EB04_SexyPrimes - marks only sexy primes
  • EB05_PrimeGap - marks neighbour primes with given gap distance
Density
  • ED01_RadiusBias - generates matrix of given size. Then each point is assigned a value equal to number of primes in a given radius. The brighter the pixel, the more primes are located around it. Actual primes can be applied a bias value - which is useful for highlighting them.
  • ED02_DiagonalConnectionsWithinRadiusWithCutoff - similar to ED01 but only primes that are placed diagonally to given point are taken into consideration. Cutoff value can be set - points with density value below this threshold will not be marked (corresponding pixels will be same as background value)

todo notes

  • matrix compression (ability to store huge matrices in a small file)
  • matrix caching - to speed up the generation process - pre-generated matrix to be read from file
  • generating large matrices is taking too much time

About

A tool for visualizing and exploring Ulam'spirals.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages