Everything2
Near Matches
Ignore Exact
Full Text
Everything2

14233221

created by bis

(thing) by bis (1.5 mon) (print)   ?   (I like it!) Thu Aug 17 2000 at 22:35:43

14233221 is the self-summarizing number to which the sequence 1, 11, 21, 1211, 1231, ... stabilizes. The sequence is similar to, but not quite the same as the Audioactive Sequence, and it does not have any name that I know of. The only times I have encountered it have been in the form of a brain teaser like this:1

Given the sequence
  • 1
  • 11
  • 21
  • 1211
  • 1231
  • 131221
  • ...
what is the next number in the sequence? What is the last number in the sequence?

The trick to this brain teaser is that every number after the first is just a summary of the digits of the previous number, as you would read them, high to low. So,

  • 1
  • one 1 -> 11
  • two 1s -> 21
  • one 2, one 1 -> 1211
  • one 2, three 1s -> 1231
  • one 3, one 2, two 1s -> 131221
  • ... and so on and so forth until you get to the last number, which repeats ad infinitum:
  • one 4, two 3s, three 2s, two 1s -> 14233221

Interestingly (or uninterestingly), the entire sequence has just 13 unique terms: 1, 11, 21, 1211, 1231, 131221, 132231, 232221, 134211, 14131231, 14231241, 24132231, 14233221, 14233221, ...

and just for fun, here's some C that solves the problem:

#include <stdio.h>
#include <stdlib.h>

unsigned nextnum(unsigned k)
{
    unsigned breakout[10];
    unsigned i;
    for(i=0; i < 10; i++)
        breakout[i]=0;

    while(k > 0)
    {
        breakout[k%10]++;
        k /= 10;
    }

    for(i=9; i > 0; i--)
        if (breakout[i]>0)
            k = k*100 + 10*breakout[i] + i;

    return k;
}

int main(int argc, char** argv)
{
    unsigned x = 1;
    unsigned i;
    unsigned max = argc > 1 ? atoi(argv[1]) : 14;
    
    printf("iteration %2i: %8i\n", 0, x);
    for(i=1; i < max; i++)
    {
        x = nextnum(x);
        printf("iteration %2i: %8i\n", i, x);
    }
    
    return 0;
}

1 This node was originally the answer to that brain teaser as written by Hermetic in A nice, hard brain teaser... which has since expired, leaving me looking like a bit of a fool.


printable version
chaos

How many chickens? ++ Brain Teaser Audioactive Sequence
stdio.h 1, 11, 21, 1211 Everything Literature ARGC
iteration Brain Teaser: Five Hats printf Number
sequence #include panic attack Toccata
ad infinitum Sabriel argv unsigned
C unique Hermetic
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
After stirring Everything, these nodes rose to the top:
Destruction of Syntax - Imagination without Strings - Words-in-Freedom
Nazca Lines
Steve Jobs
The Young Americans
Love is not an emotion
Claude Lévi-Strauss
The Eugenics Problem
George Grosz
A sandwich is not a sammich
Between the Testaments - The Hellenistic Period
Thanks from our Hearts
Matt Drudge
Stuffed full o' Nodes Day 2004
New Writeups
Glowing Fish
Tualatin River(place)
The Jacket
Words of Advice(idea)
keepinitreal
Why buy the cow when you can get the milk for free?(idea)
John_Fox
Good Intentions Gone Wrong(person)
Cuckowski
Slavonic Princess(poetry)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
Everything 2 is brought to you by the letter C and The Everything Development Company