Prime Spirals - Numberphile

  • Published on Jul 9, 2013
  • Prime numbers, Ulam Spirals and other cool numbery stuff with Dr James Grime.
    More links & stuff in full description below ↓↓↓
    James Clewett on spirals at:
    And more to come soon...
    * subscribing to numberphile does not really change your physical appearance!
    And "golden line" in this context was made up by Brady!
    Numberphile on Facebook:
    Numberphile tweets:
    Videos by Brady Haran
    Brady's videos subreddit:
    Brady's latest videos across all channels:
    Sign up for (occasional) emails:
    Numberphile T-Shirts:
    Other merchandise:
  • Science & TechnologyScience & Technology

Comments • 1 690

  • bnkjkdsbklafj hjbvjhbfdasjka

    if you skuint at it you can see stripes in the random patern
    but they aren't as vibrant, dense and long as in ulam's spiral

  • Engineer Asik
    Engineer Asik 4 days ago

    any sequence having general term tn=an²+bn+c where a,b,c are constants is called quadratic sequence

  • Engineer Asik
    Engineer Asik 4 days ago

    that quadratic polynomial is the general term for the quadratic sequence

  • huckbeduck
    huckbeduck 7 days ago

    I found an equation to find the next number, going diagonally or horizontally or vertically. (This is for all the numbers to create an ulam spiral without writing every digit). Just add 8 to the difference between two of the previous consectutive numbers of the direction you want to go. 2,10,26,50 is a diagonal for example; (50-26=24, 24+8=32, 32+50=82. "82" is the next number in the sequence.

  • Soreofhing
    Soreofhing 10 days ago

    1:16 "He was sat...". "He was seated...". There. Fixed it for you.

  • kirigata
    kirigata 13 days ago

    I wonder what those lines would look like if plotted in 3d. instead of using a square for the spiral, try a cube?

  • Simon Shugar
    Simon Shugar 16 days ago

    3:10 Wouldn't it be better to compare the prime spiral to random ODD numbers chosen instead of ALL numbers? Odds are all diagonal from each other in this spiral so it may just be that that we're seeing.

  • Max Musterman
    Max Musterman 23 days ago

    Need help. Is there a way to get the (x,y) position of any number? 1 has (0,0).

  • Supernova
    Supernova 25 days ago

    That's amazing! I love this!

  • Shivam Mishra
    Shivam Mishra 25 days ago

    The line equation is a parabolic eqn , which in the second diagram seems to be a spiral

  • Kids4 Life
    Kids4 Life Month ago

    I was doing some math and found that (2n)+(n^2)-1 created primes very well if n is even. Example: (2 x 99922222222220)+(99922222222220^2)-1 is prime. I also saw that up to 200 being n (leaving out odd numbers) it spit out a prime 42% of the time.

  • ryavix
    ryavix Month ago

    Now if only we could get these over educated folks to STOP thinking 2 dimensionally.

  • Mondo LeStraka
    Mondo LeStraka Month ago

    Love this!!

  • Andriy Makukha
    Andriy Makukha Month ago

    Ulam comes from Lviv, one of the most beautiful cities in Ukraine. There are places that he used to visit with his math buddies.

  • Krishaang Kohli
    Krishaang Kohli Month ago

    James showing his true 'attraction' for primes
    "Look at these curves."

  • BigMan Ollie
    BigMan Ollie 2 months ago

    what would happen if you were to do this with other tessellating shapes? i.e. filling in a spiral on a map of hexagons etc..?

  • saqqaq _
    saqqaq _ 2 months ago


  • K K
    K K 2 months ago

    Great video! Thanks.

  • Svsnmurty Gattimi
    Svsnmurty Gattimi 2 months ago

    I am working on Composite Numbers factors based on normal Algebra and Geometry( not divide 1,2,3,..). I need One composite number with unknown factors to find factors based on my work. please help anyone.

  • Caden Bintliff
    Caden Bintliff 2 months ago

    i eat children

  • Velma Velvet
    Velma Velvet 2 months ago

    The round one reminds me of the Earth's magnetic field.

  • Toph Morris
    Toph Morris 2 months ago

    4:49. So, when x=4, the result isn't prime? That somehow seems logical to the degree of being obvious, but I suppose it isn't since there's a +1 in the formula itself. I want to experiment with this now and see the values of x that give you prime numbers and those that don't, and compare/contrast. I can't imagine this already hasn't been done, though. Moments like this, I hate being a math pleb.

  • Robert Morgan
    Robert Morgan 2 months ago

    What if you only circle the mersenne primes?

  • Brandon Gammon
    Brandon Gammon 2 months ago

    What would a square spiral of just prime numbers look like???

  • jat green
    jat green 3 months ago

    ok, i'm writing a computer program to go in spirals checking for diagonal lines and predicting primes and checking if they are. i really want to see how many primes it comes up with and how fast it is compared to a simple primes checker that checks every number

  • Steven Wenker
    Steven Wenker 3 months ago

    Please zoom out a little bit

  • Brandon Hamer
    Brandon Hamer 3 months ago

    I wonder what it would look like if you did ulams spiral but coloured numbers according to how many prime factors each number has. All primes would be one colour, then numbers like 6, 10, 14 and 15 another colour and 8, 12, 18 and 20 another and so on. I tried looking to see if someone had done this but couldn't find anything.

  • Nin compoop
    Nin compoop 3 months ago


  • Robi_CK
    Robi_CK 3 months ago

    0:58 - Kudos for pronouncing Stanisław right, with "ł" not "l".

  • Timothy Hinkle
    Timothy Hinkle 4 months ago

    if you repeated this same experiment in more than 2 dimensions what are the results? 2,3,4...26

  • Jake Mooshian
    Jake Mooshian 4 months ago

    I would like to see Ulam's spiral using only odd numbers.

  • Nikhil Nirmal
    Nikhil Nirmal 4 months ago

    Must watch Channel Nikhil Nirmal
    Prime numbers identification easily .

  • Corpus Crewman
    Corpus Crewman 4 months ago

    I love how the primes graphed along the Archaemedian spiral result in figures that resemble logarithmic graph functions.

  • Luis Padua
    Luis Padua 4 months ago

    I'd like to see a video on the standard model lagrangian density formula.

  • Jack Kidd
    Jack Kidd 4 months ago

    what if you write the numbers in triangles, or pentagons, or hexagons....instead of a square

  • Hamza147
    Hamza147 5 months ago

    Amazing ! You remind me some of my discussions about prime numbers with a dear friend of mine when we were at high-school.

  • Axe
    Axe 5 months ago

    Long ago, I've found two interesting formule for primes: sqrt(120n+1) and sqrt(120n+49).
    For quite a lot of values of n, whenever the formula's output was an integer, it was prime. What's more, the first formula returned primes ending in 1 and 9, and the second - in 3 and 7. I haven't calculated the breakdown point (value of n where the formula returns a non-prime integer) due to lack of experience in number theory, but it seems to be quite high. Could you please look at that? Maybe not in a video, but is there any research done on this already?

  • Kai Na
    Kai Na 5 months ago

    Well primes are odd, so it appears normal to see stripes if you arrange numbers in a spiral, since odd and even numbers are intertwined

  • Venkatesh babu
    Venkatesh babu 6 months ago

    1=√1=√1/1=√1/√1=1/√1=√1×√1=- i^2 = ... , So Fibonacci series is powers of i.

  • David Tribble
    David Tribble 6 months ago

    What's so special about the primes?
    I've wondered for many years now if primes can be considered just a special case of the set of naturals having 2 divisors, Sd(2) = {2, 3, 5, 7, 11, ...}, where the next set is the naturals having 3 divisors Sd(3) = {4, 6, 9, 10, 14, 15, ...}, and so on for Sd(4), Sd(5), etc. Sd(1) is just {1}, of course. The trick, then, is to find numeric relationships between Sd(i) and Sd(j), and then generalize these to all Sd(n, for all n in N).

  • S. Smith
    S. Smith 6 months ago

    A similar concept I came up with while doodling in school too...
    Get grid paper, and do rows, draw lines through primes; they line up at various different angles

  • He Fr
    He Fr 7 months ago

    "look at those curves" -James Grime

  • Algorithm
    Algorithm 7 months ago

    I used this exact concept in 5th grade when I was just playing around with primes and trying to figure out a pattern. It's interesting to see that there is actually a pattern as I didn't notice anything when I did it. I only went up to 100 though.

  • AlekVen's stupidface
    AlekVen's stupidface 7 months ago

    You know that if you write down numbers like that, every diagonal will either contain strictly odd numbers, or even numbers, and they'll follow each other?
    Of course you'll see the pattern of primes considering that, excluding 2, every single one of those is odd, thus only lie on certain diagonals.

  • Nathan 1132
    Nathan 1132 7 months ago


  • Nathan 1132
    Nathan 1132 7 months ago

    il é ou gotaga ?

  • Nathan 1132
    Nathan 1132 7 months ago

    go 1vs1 fortnite

  • Nathan 1132
    Nathan 1132 7 months ago


  • Frank Harr
    Frank Harr 7 months ago

    You know, the primes may or may not have a patter, but the non-prime DEFFINATELY have a pattern.

  • A. Joe
    A. Joe 8 months ago

    The primes in the Archimedian spiral look very much like parabolic functions rotated 90 degrees to the left. Has anyone investigated whether there may be a complex rotation of a second order polynomial involved in creating this pattern?

  • Дмитрий Кузнецов

    I wonder if anyone tries to do real math in some other system of calculation different from decimal. may be those patterns could be seen even easier.

  • Aaron Rotenberg
    Aaron Rotenberg 8 months ago

    What do you mean 57 isn't prime? Everyone knows it's the Grothendieck prime!

  • Denis SEO
    Denis SEO 8 months ago

    So on some visual representation you can get a straight line of primes going into infinity?

  • z
    z 8 months ago

    james prime

  • thebudkellyfiles
    thebudkellyfiles 8 months ago

    Thank you for so many great and interesting videos.

  • paperEATER101
    paperEATER101 8 months ago

    I see Elvis in the "random" picture

  • Sodium Hypochlorite
    Sodium Hypochlorite 9 months ago

    It kinda looks like a swastika. I wonder if math is trying to tell us something.

  • nightmisterio
    nightmisterio 9 months ago

    Do prime visualization in base 12

  • Ted Rowell
    Ted Rowell 9 months ago

    Can someone make one of those squares where all the even numbers are in the correct location, and all the odd ones random? I wonder what that would look like.

  • Leo Yohansen
    Leo Yohansen 9 months ago

    Compare it with the graph for 6x + or - 1.

  • Xa
    Xa 9 months ago

    It seems to me that the reason the prime numbers form diagonal lines is just because they're odd. After all, if you circle all the odd numbers instead of the prime numbers, you'll get a checkerboard-like grid. Naturally, since prime numbers, besides 2, are odd, they will tend to form random diagonal lines.

  • DJ Q
    DJ Q 9 months ago

    x^2 + x + [button smash your calculator here]

  • RBWN
    RBWN 9 months ago


  • Osanne
    Osanne 9 months ago

    Could the pattern of diagonals (partially) be caused by the fact that prime numbers except two are always odd numbers?
    In such a spiral notation the odd and even numbers immediatly form a grid of odd and even number lines, and prime numbers can already only exist on half of those.
    So the difference from a completely random pattern is already visible the moment you say "the random numbers cannot be even". I doubt there would be a clear difference between odd random numbers and prime number patterns.

  • MisterNewOutlook
    MisterNewOutlook 10 months ago

    Have these spirals been tried on a sphere or within a sphere?

  • Chris Larson
    Chris Larson 10 months ago

    The cause for the diagonals appearing in the prime spiral as opposed to the chaos in the randomly generated picture is because the prime spiral creates a checkerboard between evens and odds. Essentially, if you took the random pictures and then removed all of the even, my hypothesis is that it would look similar to the prime spiral with respect to the prevalence of diagonals

  • Gunihelm Schaf
    Gunihelm Schaf 10 months ago

    I found a equation who gives u every prime number

  • Patryk Wieczorek
    Patryk Wieczorek 10 months ago

    Maths is beautiful!

  • ScarletFox
    ScarletFox 10 months ago

    What if we're thinking of this wrong.
    Every pattern like this creates a line in which no primes are possible.
    Maybe the primes are the gaps where every one of these lines from every possible pattern doesn't cover.

  • Paul White
    Paul White 10 months ago

    Wanna see how to find primes ? them onto a set of concentric circles of 24 sections each . Each section represents one sequential natural number and keep going for each larger circle. You will find them only on 8 " rays " from the centre. All very geometric .See prof. Dr. Peter Plichta's book ...god's secret formula. I believe the formula 6n + 1 or - 1 ,might be worth looking into. Cheers all

  • Sander
    Sander 10 months ago

    I'd like to see that picture of random numbers, but with the added rule that all even numbers other than 2 are excluded. This because the picture is now also filled with horizontal and vertical stripes while in the Ulam's spiral it is by definition only possible to form stripes that are diagonal.

  • CornerTalker
    CornerTalker 11 months ago

    Try putting the digits of pi in an Ulam's spiral and then marking the primes.

  • magnusee
    magnusee 11 months ago

    Dont do it in a grid. Try a honeycomb pattern

  • John Perkins
    John Perkins 11 months ago

    I would like to see the spiral with the obvious diagonals removed, then see if other diagonals become apparent.

    ROVAKAN 11 months ago

    where can i get those pictures of spirals please ?

  • Ismir Eghal
    Ismir Eghal 11 months ago

    0:23 rap career secure if maths should one day not
    work for him anymore

  • Computerman 21
    Computerman 21 11 months ago +1

    7:08 is a fingerprint

  • Anonyme Anonymes
    Anonyme Anonymes 11 months ago

    Excellent video

  • Marcelo Fernandes

    @Numberphile The patterns at @7:13 are very similar to potential flow lines around a horizontal flat plate!

  • VITA kyo
    VITA kyo Year ago

    Try an hexagonal pattern instead of squares

  • Jesse Leonard
    Jesse Leonard Year ago

    This guy and a dirty chalkboard goes hand in hand. Ugh I love numberphiles

    • Jesse Leonard
      Jesse Leonard Year ago

      If I found them in college I wouldn't have failed any math classes

  • AraChan
    AraChan Year ago

    Pucci aproves

  • Oqsy
    Oqsy Year ago

    If you keep going with the second arrangement you realize that the “basketball” is just the beginning of a pattern that looks like:


  • Banjon Pro
    Banjon Pro Year ago

    Do all mathematicians truly believe that we are in a simulation, or is it just me? It's hard to find arguments against it.

  • Khalid Salah
    Khalid Salah Year ago

    who's here for advent of code'17 day 3?

  • Erika Vega
    Erika Vega Year ago

    Love this guy!

  • My Life In A Nutshell

    The story of the Ulams spiral is written in my book of maths of high school, so I get interested,
    I knew I would find a video of Numberphile, and you guys told exactly the same story, but even better ! props for that my dudes

  • Gershom Maes
    Gershom Maes Year ago

    At times it almost feels like the *definition* of primes would be "the sequence of numbers which partially appears most frequently throughout the set of all integer functions, without ever precisely matching the results of any function".

  • RobatRobot
    RobatRobot Year ago

    What happens if you start drawing the square at 0? I note from other comments that since the pattern is formed in part due to the relationship between primes and odd numbers, I just wondered if it made any difference whether or not you start with an odd or even number. It would change the numerical-position of each corner, and hence the 45° nature of the existing pattern. What happens if you start at -1?

  • Kevin Morais
    Kevin Morais Year ago

    Factor all numbers and spot primes in between here

  • Jakob Jones
    Jakob Jones Year ago

    Whats more is that those stripes intersect in a regular array. They are equally spaced apart. You can notice the squares and they are all about the same size. I wonder if one can look at this in higher dimensions and find a pattern?

  • TheMattyBoy00
    TheMattyBoy00 Year ago +1

    After seeing this I was curious about other spirally shapes, so I wrote a quick java program to generate a 1001x1001 grid of a rhombus shape like this:
    ... 6 2 8
    13 5 1 3 9
    12 4 10
    ...and the result is rather astounding! You can see clear horizontal lines of prime numbers (but not many vertical), some of which seem to carry on for very long without much interference. Link to picture in first reply (I think some people block comments with links in them so it's best to have it separate)

  • explosu
    explosu Year ago

    I also notice some that are very sparse. If there's anything in between, it makes me wonder if there are some lines with finite primes, or completely solid

  • Galaxbee
    Galaxbee Year ago

    I wonder... If someone were to take all thos dots and indent them onto paper as braille what words could a blind person make from it??

  • anoderone
    anoderone Year ago

    So... lines with only odd numbers have more primes than lines with only even numbers: well done Sherlock!
    I tried doing the same but with only odd numbers and using a hexagonal spiral instead of square. I also get an interesting line. In the first (6n²+8n+3) there are 5 primes in the first 6 elements (3, 17, 43, 81, 131, 193), but then only 3 primes in the following 9 elements. So... meh. I think the conclusion from such a spiral done further would just be that lines with no multiples of 3 (such as 6n²+18n+13) have more primes than lines made of multipes of 3...

  • Parthian Capitalist

    So if I don't listen to lectures and just doodle, I'll become famous,

  • bruno alves
    bruno alves Year ago

    I always thought that random is an absolute thing, something either is random or it is not. Apparently prime numbers are not random, but they dont seem to form any concrete patterns either, so how can they be random and at the same time not?
    I believe that there is a formula somewhere or a way that we have not even considered or thought about to find all prime numbers.
    I just don't think that they are random if they form some kind of patterns, and as numberphile showed there are a lot of patterns. If they were random they would look like that image that he showed.
    So, if they are not random, they can be predicted, that's my belief.

  • Ostrum
    Ostrum Year ago

    at 7:04 anyone else recognise this looking a bit like part of the Mandelbrot set?

  • YipHyGaming - Truncation [150 coming]

    Died at the sack one tho