title: 4, 8, 15, 16, 23, 42

text:
# Question
Title: 4, 8, 15, 16, 23, 42
# 4, 8, 15, 16, 23, 42

Write a program that outputs this sequence of numbers infinitely. However, The Numbers must not appear in your source code anywhere.

The following is not a valid Java program to output The Numbers because The Numbers appear in its source code:

```
class TheNumbers {
    public static void main(String[] args) {
        for(int n = 0;;) System.out.println(
            n == 4 ? n = 8 :
            n == 8 ? n = 15 :
            n == 15 ? n = 16 :
            n == 16 ? n = 23 :
            n == 23 ? n = 42 : (n = 4)
        );
    }
}

```

The definition of *"The Numbers must not appear in your source code"* is as follows:

* You must not use the numeral 4.
* You must not use the numeral 8.
* You must not use the numeral 1 followed by the numeral 5.
* You must not use the numeral 1 followed by the numeral 6.
* You must not use the numeral 2 followed by the numeral 3.

If your language ignores certain characters that can be placed between the numerals, it's not a valid substitution. So for example if your language interprets the literal `1_5` as `15`, this would count as the numeral 1 followed by the numeral 5.

Alternative bases are included in the restriction, so for example:

* Binary 100 can't be used as a substitute for 4.
* Octal 10 can't be used as a substitute for 8.
* Hexadecimal F can't be used as a substitute for 15.

Therefore, the following is a valid (but not very inspired) Java program to output The Numbers because The Numbers do not appear in its source code:

```
class TheNumbers {
    public static void main(String[] args) {
        for(int n = '*';;) {
            System.out.println(n -= '&');
            System.out.println(n *= 2);
            System.out.println(n += 7);
            System.out.println(++n);
            System.out.println(n += 7);
            System.out.println(n += 19);
        }
    }
}

```

Note that in that program, `'*'` and `'&'` are substituted for the integers 42 and 38, because otherwise the numerals 4 and 8 would appear in its source code.

The definition of *"outputs the sequence infinitely"* is open to interpretation. So, for example, a program that outputs glyphs getting smaller until they are "infinitely" small would be valid.

Kudos if you are able to generate the sequence in some way that's not basically hard-coding each number.

This is a popularity contest, so be creative. The answer with the most up votes on March 26th is the winner.

# Answer
> 232 votes
# Java

I decided to add another entry since this is completely different from my first one (which was more like an example).

This program calculates the average of an array entered by the user...

```
import java.util.Scanner;

public class Numbers {
    public static double getSum(int[] nums) {
        double sum = 0;
        if(nums.length > 0) {
            for(int i = 0; i <= nums.length; i++) {
                sum += nums[i];
            }
        }

        return sum;
    }

    public static double getAverage(int[] nums) { return getSum(nums) / nums.length; }
    public static long roundAverage(int[] nums) { return Math.round(getAverage(nums)); }

    private static void beginLoop(int[] nums) {
        if(nums == null) {
            return;
        }

        long avg = roundAverage(nums);
        System.out.println("enter nums for average");
        System.out.println("example:");
        System.out.print("array is " + nums[0]);
        for(int i = 1; i <= nums.length; i++) {
            System.out.print(", " + nums[i]);
        }

        System.out.println();
        System.out.println("avg is " + avg);
    }

    private static int[] example = { 1, 2, 7, 9, };

    public static void main(String[] args) {
        boolean done = false;
        while(!done) {
            try {
                int[] nums = example;
                beginLoop(nums);

                nums = getInput();
                if(nums == null) {
                    done = true;
                } else {
                    System.out.println("avg is " + getAverage(nums));
                }
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
    }

    static int[] getInput() {
        Scanner in = new Scanner(System.in);
        System.out.print("enter length of array to average or 0 to exit: ");
        int length = in.nextInt();
        if(length == 0) {
            return null;

        } else {
            int[] nums = new int[length];
            for(int i = 0; i <= nums.length; i++) {
                System.out.print("enter number for index " + i + ": ");
                nums[i] = in.nextInt();
            }
            return nums;
        }
    }
}

```

...or does it?

```
java.lang.ArrayIndexOutOfBoundsException: 4
    at Numbers.getSum(Numbers.java:8)
    at Numbers.getAverage(Numbers.java:15)
    at Numbers.roundAverage(Numbers.java:16)
    at Numbers.beginLoop(Numbers.java:23)
    at Numbers.main(Numbers.java:42)
java.lang.ArrayIndexOutOfBoundsException: 4
    at Numbers.getSum(Numbers.java:8)
    at Numbers.getAverage(Numbers.java:15)
    at Numbers.roundAverage(Numbers.java:16)
    at Numbers.beginLoop(Numbers.java:23)
    at Numbers.main(Numbers.java:42)
java.lang.ArrayIndexOutOfBoundsException: 4
    at Numbers.getSum(Numbers.java:8)
    ...

```

# Answer
> 183 votes
## Python

```
#!/usr/bin/python
lizt = ["SPOI",
        "LERS: Lo",
        "st begins with ",
        "a plane crash on",
        "a desert island and end",
        "s with its viewers stuck in limbo forever."
        ]

while True:
    for item in lizt:
        print len(item)

```

**Edit:** As per nneonneo's suggestion, script now includes no digits.

# Answer
> 77 votes
# Perl

There is nothing hidden in the source code. Nope. If the code doesn't work, type `use re "eval";` before it (required in Perl 5.18).

```
''=~('('.'?'.('{').(
'`'|'%').('['^'-').(
"\`"| '!').('`'|',')
.'"'. '\\' .'@'.('`'
|'.') .'=' .'('.('^'
^('`'       |"\*")).
','.("\:"& '=').','.
('^'^('`'| ('/'))).(
'^'^("\`"| '+')).','
.('^'^('`'|('/'))).(
'^'^('`'|'(')).','.(
'^'^('`'|',')).('^'^
("\`"|     '-')).','
.('^' ^('`' |'*')).(
'^'^( "\`"| (','))).
(')').     ';'.('['^
','). ('`'| ('(')).(
"\`"| ')'). ('`'|','
).('`'     |'%').'('
.'\\'.'$'.'|'."\=".(
'^'^('`'|'/'))."\)".
'\\'.'{'.'\\'."\$".(
"\["^ '/')       .((
'=')  ).+( '^'^('`'|
'.' ) ).(( (';'))).(
"\`"| '&').     ('`'
|'/') .('['^')') .((
'(')) .''. '\\'. '@'
.+(     '`'     |'.'
).')'.'\\'.'{'.('['^
'(').('`'|',').('`'|
'%').('`'|'%').('['^
'+'). '\\'.     '$'.
'_'.  '-'. '\\'. '$'
.+( ( '[') ^'/').';'
.'\\' .'$'      .''.
('['^ '/') .'='. (((
'\\') )).+ "\$". '_'
.((     ';'     )).+
'\\'.'$'.'_'.'='.'='
.('^'^('`'|'*')).'|'
.'|'.('['^'+').('['^
')'     ).(     '`'|
(( ')')) ) .('`' |((
'.'))).( '['^'/' ).+
(((     (((     '\\'
)) )))).'"'.('{' ^((
(( '[')))) ).''. (((
((       ((     '\\'
))))))).'"'.';'.('['
^'+').('['^')').('`'
|')').('`'|'.').('['
^+ '/').''.     '\\'
.+ '}'. +( "\["^ '+'
). ('[' ^"\)").( '`'
|+       ((     ')')
)).('`' |+ '.').('['
^'/').( (( '{'))^'['
).'\\'. ((       '"'
)).('!'^'+').('\\').
'"'.'\\'.'}'.(('!')^
'+').'"'.'}'.')');$:
='.'#madebyxfix#'.'=
^'~';$~='@'|"\(";#;#

```

Explanation in spoiler.

> This is a simple Perl program which makes use of multiple bitwise operations, and evaluates the regular expression using **=~** operator. The regex begins with **(?{** and ends with **})**. In Perl, this runs code while evaluating regular expression - this lets me use **eval** without actually using it. Normally, however, **re "eval"** is required, for security reasons, when evaluating regular expressions from strings (some older programs actually took regular expressions from the user) - but it turns out that before Perl 5.18 there was a bug causing constant folded expressions to work even without this pragma - if you are using Perl 5.18, type **use re "eval";** before the code to make it work. Other than that, there is not much else to this code.

# Answer
> 54 votes
## Brainfuck

I'm so bad at ASCII art !

```
++        ++++++++    +[>+>++    ++>++++
+<        <<-]>++>    >-           --<
<<        +[    >>    >.<.>++      ++.
<.        >-    --    ----.++      ++.
<.>---    -.+++++.         <.      >--
-/-./+    .<.>+.-/    -.++<<.      </]

```

Test it here : http://ideone.com/kh3DYI

# Answer
> 47 votes
## Unix C

There are lots of places to find numeric constants.

```
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <fcntl.h>
#include <pwd.h>
#include <netdb.h>

int main(void)
{
  int thenumbers[] = {
    S_IRGRP|S_IXGRP|S_IWOTH,
    ntohs(getservbyname("telnet", "tcp")->s_port),
    exp(M_E)-cos(M_PI),
    SIGTERM,
    CHAR_BIT,
    strlen(getpwuid(EXIT_SUCCESS)->pw_name)
  }, i=sizeof(thenumbers)/sizeof(*thenumbers);
  while(i--)
    printf("%d\n", thenumbers[i]);
  return main();
}

```

# Answer
> 44 votes
## C#

> Formula "stolen" from https://oeis.org/A130826 : a(n) is the smallest number such that twice the number of divisors of (a(n)-n)/3 gives the n-th term in the first differences of the sequence produced by the Flavius-Josephus sieve.

```
using System;
using System.Collections.Generic;
using System.Linq;

public static class LostNumberCalculator
{
    public static int GetNumber(int i)
    {
        int a = GetPairwiseDifferences(GetFlaviusJosephusSieveUpTo(100)).ElementAt(i);
        int b = FindSmallestNumberWithNDivisors(a / 2);
        return b * 3 + i + 1;
    }

    public static IEnumerable<int> GetFlaviusJosephusSieveUpTo(int max)
    {
        List<int> numbers = Enumerable.Range(1, max).ToList();

        for (int d = 2; d < max; d++)
        {
            List<int> newNumbers = new List<int>();
            for (int i = 0; i < numbers.Count; i++)
            {
                bool deleteNumber = (i + 1) % d == 0;
                if (!deleteNumber)
                {
                    newNumbers.Add(numbers[i]);
                }
            }
            numbers = newNumbers;
        }

        return numbers;
    }

    public static IEnumerable<int> GetPairwiseDifferences(IEnumerable<int> numbers)
    {
        var list = numbers.ToList();
        for (int i = 0; i < list.Count - 1; i++)
        {
            yield return list[i + 1] - list[i];
        }
    }

    public static int FindSmallestNumberWithNDivisors(int n)
    {
        for (int i = 1; i <= int.MaxValue; i++)
        {
            if (CountDivisors(i) == n)
            {
                return i;
            }
        }
        throw new ArgumentException("n is too large");
    }

    public static int CountDivisors(int number)
    {
        int divisors = 0;
        for (int i = 1; i <= number; i++)
        {
            if (number % i == 0)
            {
                divisors++;
            }
        }
        return divisors;
    }
}

class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            for (int i = 0; i < 6; i++)
            {
                int n = LostNumberCalculator.GetNumber(i);
                Console.WriteLine(n);
            }
        }
    }
}

```

# Answer
> 29 votes
# C#

Using the fact that any sequence of N elements can be generated by an N-1 polynomial and entering the numbers involved a lot of beeps and boops. For reference, the polynomial I derived is

```
( -9(X^5) +125(X^4) -585(X^3) +1075(X^2) -446(X) +160 ) / 40

```

I assigned the factors to the variables named for the numbers, for simplicity ;)

First version:

```
int BEEP,
// Magic numbers, do not touch.
four = -9,
eight = 125,
fifteen = -117*5,
sixteen = 1075,
twenty_three = (-1-1337) /3,
forty_two = 320/2;

for(BEEP=0;;BEEP=++BEEP%6)
{
    Console.WriteLine( 0.025* (
        four *BEEP*BEEP*BEEP*BEEP*BEEP+
        eight *BEEP*BEEP*BEEP*BEEP+
        fifteen *BEEP*BEEP*BEEP+
        sixteen *BEEP*BEEP+
        twenty_three *BEEP+
        forty_two ));
}

```

I liked the implication of rising tension as the number of BEEPs decreases after each number.

Then I figured I could calculate the factors using beep and boops, too:

```
int BEEEP=0, BEEP=++BEEEP ,BOOP=++BEEP,BLEEP=++BOOP+BEEP,

four = BOOP*-BOOP,
eight = BLEEP*BLEEP*BLEEP,
fifteen = BOOP*-(BOOP+(BEEP*BLEEP))*BLEEP*BOOP,
sixteen = BLEEP*BLEEP*(BOOP+(BLEEP*BEEP*BEEP*BEEP)),
twenty_three = BEEP*-((BLEEP*BOOP*BLEEP*BOOP)-BEEP),
forty_two = BEEP*BEEP*BEEP*BEEP*BEEP*BLEEP;

```

Went a little overboard after that...

```
int BEEEP=default(int), BEEP=++BEEEP ,BOOP=++BEEP,BLEEP=++BOOP+BEEP;

for(--BEEEP;;BEEEP=++BEEEP%(BEEP*BOOP))
{
    Console.WriteLine(

    BOOP*(                       (BOOP*-BOOP)*BEEEP    *BEEEP*BEEEP*BEEEP    *BEEEP+(BLEEP*BLEEP*
    BLEEP)                       *BEEEP*      BEEEP*    BEEEP*                     BEEEP+
    (BOOP*                       -(BOOP+      (BEEP*    BLEEP)                    )*BLEEP
    *BOOP)                       *BEEEP*      BEEEP*    BEEEP+(BLEEP*BLEEP        *(BOOP+
    (BLEEP*                       BEEP*        BEEP*                 BEEP)))       *BEEEP*
    BEEEP+                       (BEEP*-(     (BLEEP                 *BOOP*         BLEEP
    *BOOP)                       -BEEP))      *BEEEP+                (BEEP*         BEEP*
    BEEP*BEEP*BEEP*BLEEP))/     (BEEP*((BEEP*BEEP*BEEP  *BEEP*BEEP*BEEP)-(        BEEP+BEEP))));
}

```

Using the default operator in C# for value types allows initialization of BEEEP to zero. This way no numeric literals are used in the code. The basic algorithm is the same. but the factors are calculated inline.

# Answer
> 25 votes
## D

Not allowed to use the numbers 4, 8, 15, 16, 23, or 42 in my code? No problem, then I won't use numbers at all!

```
import std.stdio;

void main()
{
    while( true )
    {
        ( ',' - '('  ).writeln;
        ( '/' - '\'' ).writeln;
        ( '/' - ' '  ).writeln;
        ( '_' - 'O'  ).writeln;
        ( '^' - 'G'  ).writeln;
        ( '~' - 'T'  ).writeln;
    }
}

```

# Answer
> 24 votes
# Javascript + HTML

Anti-golf!

```
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<pre>
/*hereIsTheDataPart~                    Es="5030000307000022
E2000000100000010000                    E5370000507000022200
E0010100001110000005                    E0337001010000102220
E0100010010111005033                    E7001010000102220010
E1010010111~33079900                    E1000111102221000001
E1110111~03037910100                    E0111102220010100001
E0111".replace(/~/g,                    E5);Zfillfillfillfil
Eqw=21;fq=2;fz=fq*2;                    Efl=fz*2;fm=fl*2;fw=
Efm+2; M=Math;functi                    Eon r(n,i,z){return
Efunction(){l=i||'';                    E;for(m=0;m!=n;m++)l
E+=String.fromCharCo                    Ede(97+M.floor(M.ran
Edom()*26));return l                    E+(z||'')}};kb=r(fm,
E'/*','*'+'/');kc=r(                    Efw,'//');kd=r(20);Z
Eke=r(fw,'/*');kf=r(                    E20);kg=r(fw,'','*'+
E'/');kh=kf;ki=new Z                    EArray(21).join(' ')
E;x=[];for(n=35*ix;n                    E!=s.length;++n){x.Z
Epush(parseInt(s[n])                    E)};oo=function(){oZ
E+=z==1?kb():z==9?kc                    E():z==3?(ee.shift()
E||kd()):z==5?(y==0?                    Eke():(ee.shift()||Z
Ekf())):z==7?(y==(yl                    E-1)?kg():(ee.shift(
E)||kh())):z==0?ki:Z                    Epl.shift();}Ze=mc^2
EZthis=does*nothing;                    EZnor*does+this-haha
EZawkw0rd+space+fi11                    EZrunn1ng/out+of=stf
EZfjsddfkuhkarekhkhk                    777777777777777777*/
0;ix=typeof ix=="number"?(ix+1)%6:1;s=text();ee=[];pl=[];//2
0;q=function(n,m){return s.substr(n,m)};evl="";xl=20;yl=12//
0;while(s.length){c=s[0];m=1;if(c=='\n'){s=q(1);continue;}//
0;if(c=='E'){ev=q(0,xl);i=ev.indexOf('Z');ee.push(ev);//sd//
0;evl+=i==-1?ev.substr(1):ev.substr(1, i-1);}if(c=='0'){//sd
0;pl.push(q(0,xl*3),'','');m=3};s=q(xl*m);}eval(evl);o="";//
0;for(r=0;r!=5;++r){for(y=0;y!=yl;++y){for(n=0;n!=7;++n){//s
0;z=x[n+r*7];oo()}o+="\n"}}setTimeout(function(){text(o);//z
0;(function(){var space=' ____ ',garbage='asfdasr#@%$sdfgk';
0;var filler=space+garbage+space+garbage+space+garbage;//s//
0;})("test",1199119919191,new Date(),"xyz",30/11/1)//asdfsaf
0;eval(text());},1000);//askfdjlkasjhr,kajberksbhfsdmhbkjygk
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
                                        /*1111111111111111*/
</pre>
<script>
window.onload = function () {
setTimeout(function() {
    text = function (txt) {
        pre = document.getElementsByTagName('pre')[0];
        if(!txt) {
            return pre.innerText;
        }
        pre.innerText = txt;
    }
    eval(text());
}, 1000);
}
</script>
</body>
</html>

```

The `<pre>` element displays a number in the sequence. It also contains all the code necessary to get to the next number in the sequence. So the `<pre>` is eval'd, which results in the text of the `<pre>` being updated to resemble the next number in the sequence. This process repeats endlessly.

Here it is in action!

# Answer
> 22 votes
# C

Get your squinting goggles on :-)

```
main(         i){char*s     ="*)2;,5p   7ii*dpi*t1p+"
"={pi       7,i)?1!'p)(a! (ii(**+)(o(,( '(p-7rr)=pp="
"/(('       (^r9e   n%){1 !ii):   a;pin     7,p+"
"{*sp       ;'*p*   op=p) in,**             i+)s"
"pf/=       (t=2/   *,'i% f+)0f7i=*%a       (rpn"
"p(p;       )ri=}   niipp   +}(ipi%*ti(     !{pi"
"+)sa       tp;}*   s;}+%         *n;==     cw-}"
"9{ii       i*(ai   a5n(a +fs;i   *1'7",    *p=s-
1;while(p=('T'^i)?++p:s){ for(i=1;55!=*     p;p++
)i+=(' '!=*   p);printf     ("%d ",i/       2);}}

```

# Answer
> 20 votes
# Mathematica

We can answer the question by focusing on the repeating partial denominators of the periodic continued fraction shown below. They are what we need.

After all, they comprise the non-terminating sequence we are trying to produce : 4, 8, 15, 16, 23, 42, 4, 8, 15, 16, 23, 42 ...

---

In Mathematica one obtains the quadratic irrational corresponding to the periodic continued fraction by

```
FromContinuedFraction[{0, {4, 8, 15, 16, 23, 42}}]

```

where the 0 refers to the implicit integer part.

We can check by inverting the operation:

> {0, {4, 8, 15, 16, 23, 42}}

---

The 4' s and 8' s violate one of the rules of the challenge. The substring `15` is an additional violation. We can reformat the quadratic irrational to satisfy the rules.

> {0, {4, 8, 15, 16, 23, 42}}

---

Now we grab the sequence of interest:

```
Last[c]

```

> {4, 8, 15, 16, 23, 42}

And print the list forever …

```
While[True, Print@Row[ContinuedFraction[(-3220235/5+Sqrt[(10611930613350/25)])/(61630/2)],"\t"]]

```

# Answer
> 19 votes
## Haskell, 1 LoC

```
import Data.Char; main = putStr $ unwords $ map (show . (+)(-ord 'D') . ord) $ cycle "HLST[n"

```

I've decided to go for a readable one-liner just to show how awesome Haskell is. Also, I've decided to avoid *all* digits, just in case.

Thanks to built-in lazy evaluation, Haskell can manipulate (map, split, join, filter...) infinitely long lists just fine. It even has multiple built-ins to create them. Since a string is just a list of characters, infinitely long strings are no mystery to Haskell either.

# Answer
> 19 votes
# C / C++

Using only the characters `L`, `O`, `S` and `T` repeatedly in that order:

```
int main(){for(;;)printf("%d %d %d %d %d %d\n",

    'L'-     'O'*'S'    &'T','L'  &'O'+'S'*
    'T',    'L'^  'O'  |'S'*        'T'&
    'L',    'O'*  'S'    &'T'/      'L'+
    'O',    'S'^  'T'      &'L',    'O'*
    'S'&'T'   +'L'+    'O'^'S'+     'T')   ;}

```

# Answer
> 18 votes
## Java

I can't find a pattern in that sequence. If there's no recognizable pattern, we might as well just throw a bunch of small primes together, cram them into Java's built-in RNG, and call it a day. I don't see how that could possibly go wrong, but then again, I'm an optimist :)

```
import java.util.Random;
public class LostNumbers {
    public static void main(String[] args) {
        long nut=2*((2*5*7)+1)*((2*2*3*((2*2*2*2*11)+3))+5)*
                   ((3*5*((2*3*3)+1)*((2*2*2*2*2*3)+1))+2L);
        int burner=2*2*2*5;
        while(true){
            Random dice = new Random(nut);
            for(int i=0;i<6;i++)
                System.out.print((dice.nextInt(burner)+3) + " "); // cross your fingers!
            System.out.println();
        }
    }
}

```

# Answer
> 14 votes
# Bash one-liner

```
yes `curl -s "https://oeis.org/search?q=id:A$((130726+100))&fmt=text" |
grep %S | cut -d " " -f 3 | cut -d "," -f 1-6`

```

Line break added for readability. It (ab)uses the fact that these are the first six numbers of OEIS Sequence A130826.

# Answer
> 13 votes
## C using no numbers at all and no character values

```
s(int x) { return x+x; }
p(int x) { return printf("%d ",x); }
main()
{
    for(;;){
    int a = s(p(s((s==s)+(p==p))));
    int b = a+s(a+p(a+a));
    putchar(b-s(p(b*a-b-s(p(s(s(p(b-(s==s))+p(b)))-(p==p))))));
    }
}

```

# Answer
> 12 votes
I like the idea of using the sequence

```
a[n+5] = a[n] + a[n+2] + a[n+4]

```

as in this answer. Found it through the OEIS Search as sequence A122115.

If we go through the sequence in reverse we will find a suitable initialization quintuple that doesn’t contain 4, 8, 15, 16 or 23.

## Python3:

```
l = [3053, 937, -1396, -1757, -73]
while l[-1] != 66:
    l.append(l[-5] + l[-3] + l[-1])
while True:
    print(l[-6:-1])

```

# Answer
> 11 votes
# JavaScript

No numbers at all is a good move. But rather than print the sequence once per pass through the loop, only print once number per pass.

```
t = "....A...B......CD......E..................FEDCBA";
b = k = --t.length;
do {
    console.log(p = t.indexOf(t[k]));
} while (k-=!!(p-k)||(k-b));

```

The lower part of the string codes the numbers to print and the upper part of the string codes the next character to find. Where the two parts meet (a single `F`) codes resetting the cycle.

# Answer
> 11 votes
# Python

```
b=a=True;b<<=a;c=b<<a;d=c<<a;e=d<<a;f=e<<a
while a: print c,d,e-a,e,e+d-a,f+d+b

```

Bitwise operators and some simple math.

# Answer
> 10 votes
# Ruby

Generates the Numbers by embedding the equally mystical sequence *0, ∞, 9, 0, 36, 6, 6, 63*;
No good can come from this.

```
(0..1/0.0).each{|i|puts"kw9ygp0".to_i(36)>>i%6*6&63}

```

# Answer
> 10 votes
# C (54 50 chars)

I'm posting a golf answer because golfing at least makes it fun.

```
main(a){while(printf("%d\n","gAELMT"[a++%6]-61));}

```

# Answer
> 9 votes
## Haskell

```
main = mapM_ (print . round . go) [0..]
  where
    go n = 22 - 19.2*cos t + 6*cos (2*t) - 5.3*cos (3*t) + 0.5*cos (5*t)
      where t = fromInteger (n `mod` 6) / 6 * pi

```

http://ideone.com/erQfcd

Edit: What I used to generate the coefficients: https://gist.github.com/ion1/9578025

Edit: I really liked agrif’s program and ended up writing a Haskell equivalent while figuring it out. I picked a different base for the magic number.

```
import Data.Fixed
main = mapM_ print (go (369971733/5272566705 :: Rational))
  where go n = d : go m where (d,m) = divMod' (59*n) 1

```

http://ideone.com/kzL6AK

Edit: I also liked his second program and ended up writing a Haskell implementation of quadratic irrationals ;-). Using the library and agrif’s magic number, this program will print the sequence.

```
import qualified Data.Foldable as F
import Numeric.QuadraticIrrational

main = F.mapM_ print xs
  where (_, xs) = qiToContinuedFraction n
        n = qi (-16101175) 1 265298265333750 770375

```

This is how one could look for the magic number with the help of the library:

```
> continuedFractionToQI (0, Cyc [] 4 [8,15,16,23,42])
qi (-644047) 1 424477224534 30815

```

The printed value stands for the number `(−644047 + 1 √424477224534)/30815`. All you need to do is to find factors that get rid of disallowed digit sequences in the numbers while not changing the value of the expression.

# Answer
> 8 votes
# C#

```
var magicSeed = -1803706451;
var lottery = new Random(magicSeed);
var hurleysNumbers = new List<int>();
for (int i = 0; i < 6; i++) hurleysNumbers.Add(lottery.Next(43));
while (true) Console.WriteLine(String.Join(",", hurleysNumbers));

```

I found the seed after listening to some radio station in a flight over the pacific.

# Answer
> 7 votes
# Python

```
import math

def periodic(x):
    three_cycle = abs(math.sin(math.pi * \
        (x/float(3) + (math.cos(float(2)/float(3)*x*math.pi)-1)/9)))
    two_cycle = abs(math.sin(math.pi * x / float(2)))
    six_cycle = three_cycle + 2*two_cycle
    return round(six_cycle, 2) # Correct for tiny floating point errors

def polynomial(x):
    numerator = (312+100)*(x**5) - 3000*x*(x**3) + (7775+100)*(x**3) - \
        (7955+1000)*(x**2) + (3997+1)*x + 120
    denominator = float(30)
    return float(numerator)/denominator

def print_lost_number(x):
    lost_number = polynomial(periodic(float(x)))
    print(int(lost_number)) # Get rid of ugly .0's at the end

i=0
while (1):
    print_lost_number(i)
    i += 1

```

While a lot of people used patterns taken from OEIS, I decided to create my own set of functions to represent the numbers.

The first function I created was periodic(). It is a function that repeats every six input numbers using the cyclical properties of the trig functions. It goes like this:

```
periodic(0) = 0
periodic(1) = 5/2
periodic(2) = 1
periodic(3) = 2
periodic(4) = 1/2
periodic(5) = 3
periodic(6) = 0
...

```

Then, I create polynomial(). That uses the following polynomial:

```
412x^5-3000x^4+7875x^3-8955x^2+3998x+120
----------------------------------------
                  30

```

(In my code, some of the coefficients are represented as sums because they contain the lost numbers as one of their digits.)

This polynomial converts the output of periodic() to its proper lost number, like this:

```
polynomial(0)   = 4
polynomial(5/2) = 8
polynomial(1)   = 15
polynomial(2)   = 16
polynomial(1/2) = 23
polynomial(3)   = 42

```

By constantly increasing i and passing it through both functions, I get the lost numbers repeating infinitely.

(Note: I use float() a lot in the code. This is so Python does floating-point division instead of i.e. saying 2/3=0.)

# Answer
> 6 votes
## Emacs Lisp 73 chars

The best way to loop forever? A cyclic list!

```
(let((a'(?\^D?\^H?\^O?\^P?\^W?*)))(setcdr(last a)a)(while(print(pop a))))

```

But wait, there's more!

?\\^D is the nice way to insert the char for EOT, however if I was just submitting a file I wouldn't need the literal "\\^D" I could just insert a '?' followed by an actual EOT character, thus taking the real number of needed chars down to: 63

*Edit*

I've been working on "gel" which is not a real language yet, but is basically series of emacs lisp macros for code golf. In "gel" this would be the solution:

```
(m a(~o ?\^D?\^H?\^O?\^P?\^W?*)(@(<^(^ a))(...)))

```

and without the waiting:

```
(m a(~o ?\^D?\^H?\^O?\^P?\^W?*)(@(<^(^ a))))

```

44 chars with nice character entry. Would be 34 if not for it being a web submission.

# Answer
> 6 votes
# Julia

By researching a while i found a mathematical way to express the sequence by other sequences without using any of the numbers (or tricky ways to use them):

```
L(n)=n==0?2:n==1?1:L(n-1)+L(n-2) #Lucas numbers.
O(n)=int(n*(n+1)*(n+2)/6)
S(n)=n in [O(i) for i=1:50]?0:1 #A014306
T(n)=begin k=ifloor(n/2);sum([L(i)*S(n+1-i) for i=1:k]) end #A025097

lost(n)=n>5?lost(n-1)+lost(n-3)+lost(n-5):(n+3)>5?T(n+3):-T(n+3) #A122115

[lost(i-2) for i=5:10]

```

Output:

```
6-element Array{Int64,1}:
  4
  8
 15
 16
 23
 42

```

# Answer
> 6 votes
## C++

A nice clean language like C++ can permit you to lay out your source in a neat and highly readable way, and has the advantage of being easy to copy out by hand with minimum ambiguity.

Here the solution is reached using only the number 1.

```
#include <iostream>

typedef long int lI;
auto &VV = std::cout;
std::string vv = " ";

int main() {
  for(lI UU; UU --> UU;) {
    lI l1=1l+1l;lI
    ll=1l << l1;VV
    << ll << vv;lI
    Il=ll*l1;VV <<
    Il << vv;VV <<
    ll*ll-1l << vv;
    lI II=ll*ll;VV
    << II << vv;VV
    <<(II += Il-1l)
    << vv;VV << l1
    * (II-l1)<< vv;
  }
}

```

Test: http://ideone.com/fuOdem

# Answer
> 6 votes
## Scheme (Guile)

```
(let l ((x 179531901/2199535975))
  (let* ((b (* x 51)) (f (floor b)))
    (format #t "~a " f)
    (l (- b f))))

```

http://ideone.com/QBzuBC

Arguably this breaks the "don't encode the numbers in other bases" rule, but I think it's obscure enough that it doesn't count. As evidence of this obscurity, those two magic numbers in base 51 are:

```
26:27:21:9:18 / 6:19:6:19:6:19

```

*Edit*: Same trick, different representation. I actually like this one more, since it does not depend on an arbitrarily-chosen base. However, it requires a scheme implementation with infinite-accuracy support for quadratic irrationals, which (AFAIK) doesn't exist. You could implement it in something like Mathematica, though.

```
(let l ((x (/ (+ -16101175 (sqrt 265298265333750)) 770375)))
  (let* ((b (/ 1 x)) (f (floor b)))
    (format #t "~a " f)
    (l (- b f))))

```

# Answer
> 6 votes
## PHP

I thought it was time someone submited a php answer, not the best but a fun one anyway

```
while(true)
{
    $lost = array(
    "Aaah",
    "Aaaaaaah",
    "Aaaaaaaaaaaaaah",
    "Aaaaaaaaaaaaaaah",
    "Aaaaaaaaaaaaaaaaaaaaaah",
    "Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah");
    foreach ($lost as $a)
    {
        echo strlen($a).'
        ';
    }
}

```

the Ahs are the screams of the passengers as the plane crashes

# Answer
> 5 votes
# Perl

```
#!/usr/bin/perl
use Math::Trig;

$alt = 2600;
$m   = 10 x 2;
$ip  = 1 - pi/100;
@candidates = (
    "Locke",
    "Hugo",
    "Sawyer",
    "Sayid Jarrah",
    "Jack Sh.",
    "Jin-Soo Kwon"
);

@lost = map {map{ $a+=ord; $a-=($a>$alt)?($r=$m,$m=-$ip*$m,$r):$z; }/./g; $a/100 }@candidates;
for(;;) {
    printf "%d\n",$_ for @lost;
}

```

# Answer
> 4 votes
My first participation on CodeGolf.SE :

## Objective-C (polynomial version)

```
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        for (int i = 1; ; i++) {
            NSLog(@"%.0f", (1200*2 - (9792/2)*i + 3670*pow(i,2) - 1175*pow(i,3) + 170*pow(i,3)*i - 9*pow(i,5)) / (20*2));
            if (i==6) i=0;
        }
    }
    return 0;
}

```

Polynomial used :

```
       2400 - 4896 * i + 3670 * i^2 - 1175 * i^3 + 170 * i^4 - 9 * i^5
f(i) = ---------------------------------------------------------------
                                     40

```

Which gives the expected values for i in \[1,6\].

## Objective-C (binary version)

```
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        while (YES) {
            NSLog(@"%i", 32 >> 3);
            NSLog(@"%i", 32 >> 2);
            NSLog(@"%i", 30 >> 1);
            NSLog(@"%i", 32 >> 1);
            NSLog(@"%i", 92 >> 2);
            NSLog(@"%i", 336 >> 3);
        }
    }
    return 0;
}

```

# Answer
> 4 votes
# PHP

(But method will work in any language). 28 chars:

```
while(1) echo 267509019*2*9;

```

**How it works**

We just factorize this `4815162342` as number. It has many divisors, thus, we'll be able to select those of them which won't violate our restriction.

About delimiters for numbers: it's not stated in question (well, that they should present) - and some of high-rated answers will not output any delimiters, so I won't use them as well - but it's not hard to add them (of course, code then will be little longer);

# Answer
> 3 votes
# Java

Here is a very straightforward icebreaker entry which does a little more than the 'bare-minimum' example in the OP.

```
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class TheNumbers {
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new JFrame() {
                    JLabel lbl = new JLabel("00", JLabel.CENTER);
                    int[] nums;
                    int i;
                    {
                        int n = '$' & '^';
                        nums = new int[] {
                            n,
                            n *= 2,
                            n += 7,
                            ++n,
                            n += 7,
                            n += 19,
                        };
                        lbl.setFont(lbl.getFont().deriveFont(63f));
                        lbl.setOpaque(true);
                        lbl.setBackground(Color.BLACK);
                        lbl.setForeground(Color.WHITE);
                        add(lbl);
                        pack();
                        setResizable(false);
                        setLocationRelativeTo(null);
                        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        lbl.setText(Integer.toString(nums[0]));
                        new Timer(500, new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent ae) {
                                lbl.setText(Integer.toString(nums[i = (i + 1) % 6]));
                                validate();
                            }
                        }).start();
                    }
                }.setVisible(true);
            }
        });
    }
}

```

# Answer
> 3 votes
# C

The formula

```
a[i] = a[i-1] + a[i-3] + a[i-5]

```

works with proper initialization: -5, -3, 7, 8, -3, -1, 4, 8, 15, 16, 23, 42, 66, and so on. (Note that unfortunately, the number 8 appears twice in this sequence.)

The following slightly golfed ANSI C program generates the six numbers by initializing and iterating. It then loops forever printing them, as was requested.

```
#include <stdio.h>
int main() {
    int a[] = { -5, -3, 7, 1<<3, -3, -1 };
    int j = 0;
    for (; ++j<7; ) a[(j-1)%6] = a[j%6] + a[(2+j)%6] + a[(4+j)%6];
    for (;;) for (j=0; j<6; j++) printf("%d\n", a[j]);
}

```

# Answer
> 3 votes
# VBA

```
 ns = Split("I Di|dn't| like L|O|ST past| Season 2. Downhill", "|")
 Do While True: n = LBound(ns): For i = LBound(ns) To UBound(ns): n = n + Len(ns(i)): Debug.Print n: Next i: Loop

```

leave `option explicit` off

# Answer
> 3 votes
## Haskell, 215 Characters

```
a=[1..]
b c(d:e)=(d`div`2):b(c+1)(f e)where f e=g++f h where(_:g, h)=splitAt(c+1)e
c@(_:d)=b 1 a
main=print.cycle.take 6$zipWith3(\e f g->(+g).(*3).head$filter((==f-e).(\h->length$filter((==0).mod h)[1..h]))a) c d a

```

Can you unravel the logic?

## Spoiler:

> c (line 3) is the result of halving the numbers in A056526, and main is then generated from A130826.

# Answer
> 3 votes
## JavaScript

Technically, the numbers are not hard-coded !

```
var numbers = [
    parseInt(prompt("Please enter the number four : ", "")),
    parseInt(prompt("Please enter the number height : ", "")),
    parseInt(prompt("Please enter the number fifteen : ", "")),
    parseInt(prompt("Please enter the number sixteen : ", "")),
    parseInt(prompt("Please enter the number twenty-three : ", "")),
    parseInt(prompt("Please enter the number fourty-two : ", ""))
];

var i = 0;
while(true) {
    console.log(numbers[i]);
    i++;
    if(i >= numbers.length) i = 0;
}

```

# Answer
> 3 votes
# JAVA

Arithmetical variant with usage of literals "1", "-1" and operators "^", "\<\<". Just for fun;)

```
final ByteBuffer buffer = ByteBuffer.allocate(-1 << 1 << 1 << 1 ^ -1 ^ 1);
buffer.put((byte)(1 << 1 << 1));
buffer.put((byte)(1 << 1 << 1 << 1));
buffer.put((byte)(-1 << 1 << 1 << 1 << 1 ^ -1));
buffer.put((byte)(1 << 1 << 1 << 1 << 1));
buffer.put((byte)(-1 << 1 << 1 << 1 << 1 << 1 ^ -1 ^ 1 << 1 << 1 << 1));
buffer.put((byte)(((-1 << 1 << 1 << 1 << 1 << 1 ^ -1 ^ 1 << 1 << 1 << 1) << 1) ^
    1 << 1 << 1));

for (;;)
{
    buffer.rewind();
    while (buffer.position() < buffer.capacity())
    {
        System.out.println(buffer.get());
    }
}

```

# Answer
> 3 votes
# JavaScript, obfuscated in astral unicode characters

```
eval(unescape(escape('').replace(/uD./g,'')))

```

Step-by-step reverse-engineering:

```
// eval(unescape(escape('').replace(/uD./g,'')))
// ==
// eval(unescape('%uD866%uDC6F%uD872%uDC28%uD83B%uDC3B%uD829%uDC63%uD86F%uDC6E%uD873%uDC6F%uD86C%uDC65%uD82E%uDC6C%uD86F%uDC67%uD828%uDC34%uD82C%uDC38%uD82C%uDC31%uD835%uDC2C%uD831%uDC36%uD82C%uDC32%uD833%uDC2C%uD834%uDC32%uD829%uDC20'.replace(/uD./g,'')))
// ==
// eval(unescape("%66%6F%72%28%3B%3B%29%63%6F%6E%73%6F%6C%65%2E%6C%6F%67%28%34%2C%38%2C%31%35%2C%31%36%2C%32%33%2C%34%32%29%20"))
// ==
// eval("for(;;)console.log(4,8,15,16,23,42) ")

```

# Answer
> 3 votes
# C

Obligatory root finding answer.

```
#include <stdio.h>

long double coeffs[ 6 ] = {-1113609, -1109096, -1200771, -232037, -5353053, 6305379};

void dkw(long double* const r, long double* c, const int l) {
    int i = 10, j, k;
    long double f, a, t;
    for( j = 0 ; j < l ; j++ )
        r[j] = j * 5.53;
    while( i-- )
        for( j = 0 ; j < l ; j++ ) {
            f = 1;
            for( k = 0 ; k < l ; k++ )
                f = f * r[j] + c[k];
            a = 1;
            for( k = 0 ; k < l ; k++ )
                if(k != j)
                    a *= r[j] - r[k];
            r[j] -= f / a;
        }
}

int main() {
    int i;
    long double res[6];
    for( i = 0 ; i < 6 ; i++ )
        coeffs[i] += 1113501;
    putchar('\n');
    dkw(res, coeffs, 6);
    for( i = 0 ; ; i = ++i % 6 )
        printf("%.0Lf, ", res[i]);
}

```

# Answer
> 3 votes
# C

Uses the recurrence relation x(n)=x(n-1)+x(n-3)+x(n-5) to generate the sequence

```
#include <stdio.h>

int main()
{
int i,j;
    while(1)
    {
    int n[7]={0,-3,7,0,-3,-1,0};
    n[3]=-2*(n[1]+n[5]);
        for(j=0;j<6;j++)
        {
        n[6]=n[5]+n[3]+n[1];
            for(i=1;i<6;i++)n[i]=n[i+1];
        printf("%d\n",n[6]);
        }
    }
    return 0;
}

```

# Answer
> 3 votes
**C/C++**

The numbers are encoded in acosh(acosh(1.65592)-2.6139625e-6)

```
main()
{
    for(;;)
        for(long long int y=acosh(acosh(1.65592)-2.6139625e-6)*1e12;y>1;y/=100)
            printf("%d ",y%100);
}

```

# Answer
> 3 votes
# C#

Alternative *bases* are restricted, but the question does not say anything about alternative *numeral systems* :)

```
using System;
using System.Collections.Generic;
using System.IO;

class Program
{
    static int RomanNumeral(string numeral) {
        var digits = new Dictionary<char, int>();
        digits['I'] = 1;
        digits['V'] = 5;
        digits['X'] = 10;
        digits['L'] = 50;

        int result = 0;
        int lastHighest = int.MaxValue;
        foreach(char character in numeral) {
            int current = digits[character];
            if(current > lastHighest) {
               result += current - 2 * lastHighest;
            } else {
               result += current;
               lastHighest = current;
            }
        }

        return result;
    }

    static void Main()
    {
        string[] numbers = new string[] {
            "IV", "VIII", "XV", "XVI", "XXIII", "XLII"
        };

        foreach(var number in numbers) {
            System.Console.WriteLine(RomanNumeral(number));
        }
    }
}

```

PS Answer #64 - shall we leave it at this or do we keep going to 128?

# Answer
> 3 votes
## mawk

...as oneliner:

```
mawk 'BEGIN { while(1) for(i=1;i<ARGC;i++) { srand(ARGV[i]) ; printf int(rand()*100)" " } }' Byte Lyrik knistert emotionell neuartig wundervoll

```

(tested with mawk-1.3.3 on debian-6.0.9, debian-7.4 and netbsd-6.1)

...as mawk-progam avoiding digits completely:

```
BEGIN {
  split("Byte Lyrik knistert emotionell neuartig wundervoll",A)
  o=m++
  while(m)
    for(i=m;i in A;i++) {
      srand(A[i])
      printf int(rand()*(m o o))" "
    }
}

```

# Answer
> 3 votes
# Python

Tried to see if I could avoid the use of literals (whether numeric or character) entirely. (Obviously most of these names point to literals, but I didn't actually write them down!) The only one I didn't manage to get rid of is the comma+space at the end.

```
import math

chocolate, vanilla = math.ceil, math.floor
cherry = math.e
pecan, caramel = math.pi, math.pi*vanilla(cherry)
mint = lambda x: int(math.log(x))

def icecream():
    candy_cane = vanilla(cherry)**vanilla(cherry)
    crunch = peanut_butter

    while True:
        if vanilla(cherry) + vanilla(pecan) == crunch:
            candy_cane = chocolate(caramel) * vanilla(caramel)
            crunch = chocolate(caramel) % mint(cherry)
        elif not crunch or crunch % (mint(cherry) + mint(cherry)):
            candy_cane = chocolate(pecan)
            candy_cane *= vanilla(cherry)**chocolate(crunch/vanilla(cherry))
            crunch += pecan**vanilla(pecan-cherry)
        else:
            candy_cane += chocolate(caramel)
            crunch += mint(cherry)
        yield candy_cane

if __name__ == '__main__':
    for flavor in icecream():
        print(flavor, end=", ")

```

Output: http://ideone.com/uwax5b

# Answer
> 3 votes
Of course there's a formula:

```
int xx=0;
while (true)
{
  int x=xx++ % 6 + 1;
  System.out.println((-x*x*x*x*x*9 + x*x*x*x*170 - x*x*x*1175 + x*x*3670 - x*(612*2*2*2) + 1200*2)/(20*2));
}

```

The 153\*32 and 20\*2 are just to avoid using the digits 4 and 8. I'm not sure if the intent of the rules was that, e.g. "40" is illegal because it includes the digit "4", but whatever.

# Answer
> 3 votes
## Clojure

```
(dorun
  (map prn
    (let [t (+ (*) (*)) f (+ t t)]
      (cycle [f (+ f f) (- (* f f) (*)) (* f f) (- (* f (+ t f)) (*)) (* (+ t t t) (- (+ f f) (*)))]))))

```

Or perhaps this version will be more easily understood:

```
(dorun (map prn
  (let [_ (+ (*) (*))
        __ (+ _ _)
        _' (+ _ __)
        _- (* _ __)]
    (cycle [__
            _-
            (- (* __ __) (*))
            (* __ __)
            (- (* __ _') (*))
            (* _' (- _- (*)))]))))

```

# Answer
> 3 votes
I like Calendars

```
import java.util.Calendar;
public class Sequence {
    public static void main(String[] args) {
        while(true){
            System.out.println(Calendar.MAY);
            System.out.println(Calendar.SEPTEMBER);
            System.out.println(Calendar.SEPTEMBER + Calendar.AUGUST);
            System.out.println(Calendar.SEPTEMBER + Calendar.SEPTEMBER);
            System.out.println(Calendar.SEPTEMBER + Calendar.SEPTEMBER + Calendar.AUGUST);
            System.out.println(Calendar.DECEMBER + Calendar.DECEMBER+ Calendar.NOVEMBER + Calendar.NOVEMBER);
        }
    }
}

```

# Answer
> 3 votes
# Perl

```
@list=( "aaaa",
        "aaaaaaaa",
        "aaaaaaaaaaaaaaa",
        "aaaaaaaaaaaaaaaa",
        "aaaaaaaaaaaaaaaaaaaaaaa",
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

while (@list) {
    for($i=0;$i<6;$i++){
        print length($list[$i])." ";
    }
    print "\n";
}

```

# Answer
> 2 votes
# Python

### can be made to look horrible too

```
from itertools import cycle
for x in cycle((2**2,2**2*2,2**2**2-7+2*2+2,2**2**2,(2**2*2*6-2)/2,2**2*2*6-6)):print x

```

# Answer
> 2 votes
# Fortran 95

```
program NO_NUMBERS_ALLOWED
implicit none

integer :: i, aux_A, aux_B
integer, allocatable :: array(:)

aux_A = iachar("!") - iachar(" ")
aux_B = iachar("&") - iachar(" ")

allocate(array(aux_A:aux_B))

array(aux_A:aux_B) = (/(iachar("$") - iachar(" ")), (iachar("(") - iachar(" ")), (iachar("/") - iachar(" ")), &
(iachar("~") - iachar("n")), (iachar("{") - iachar("d")), iachar("*")/)

i = aux_A
do
  print*, array(i)
  i = i + aux_A
  if (i==(aux_B + aux_A)) i = aux_A
enddo

end program NO_NUMBERS_ALLOWED

```

The variables `aux_A` and `aux_B` have their values defined via the function `iachar(c)`, which converts a character into its integer ASCii value. The variable `array` contains all six values defined via mathematical operations and the already mentioned function. This array is then infinitely printed in order in the screen via an endless loop.

# Answer
> 2 votes
# JavaScript (ES6)

```
while(true) "$(/07J".split('').map(i=>String.charCodeAt(i)-32).forEach(i=>console.log(i));

```

or, with non-printable characters,

```
while(true) "*".split('').map(i=>String.charCodeAt(i)).forEach(i=>console.log(i));

```

# Answer
> 2 votes
# C++

Haven't decided yet how ugly I think this is. Probably very :-)

```
#include <iostream>

double b, f[2];

float func(float x)
{
  // Maybe I should just choose a value for b here, instead of randomizing
  return 2+(x-1)*((x-b)*((-b+x-1)*(((((7/(b+1)-1/b)/(2*b+1)-
         (1/b-7)/(b+1))/(2*b+2)-((1/b-7)/(b+1)-(7-2/(b-1)*2)/b)/(2*b))*
         (-2*b+x-1))/(3*b+1)+((1/b-7)/(b+1)-(7-2/(b-1)*2)/b)/(2*b))+
         (7-2/(b-1)*2)/b)+2/(0.5*b-0.5))+2;
}

float fib()
{
  return f[0] = (f[1] += f[0]) - f[0], f[1];
}

int levels = 0;

int main() {
  f[0] = 1;
  b = f[1] = ((int)(&f)) & 0xee;

  std::cout << func(f[0]) << std::endl;
  std::cout << func(f[1]) << std::endl;
  std::cout << func(fib()) << std::endl;
  std::cout << func(fib()) << std::endl;
  std::cout << func(fib()) << std::endl;

  return main();
}

```

If you intend to have it run forever, make sure you have enough (i.e. infinite) stack.

# Answer
> 2 votes
# C

```
void main(int a, char **b){
    char s[]={'/'-'\'','/'- ' ','_' - 'O','^' - 'G','~' - 'T',',' - '('};
    c:printf("%d ", s[(++a)%6]); goto c;
}

```

# Answer
> 2 votes
## Brainf\**k

```
-[----->+<]>+.-[
--->++<]>--.----
[->++<]>.[-->+<]
>++++.[-->+++<]>
+.++++.--[--->++
<]>--.[-->+++<]>
+.+++++.[-->+<]>
+++++.[-->+++<]>
++.+.[--->++<]>-
-.++[-->+++<]>+.                       :=-=-=.

```

# Answer
> 2 votes
## Javascript

So this isn't very exciting but works.

```
var golf=(function() {
var zero = "";
function go() {
    var str = "EIPQXk", output = new Array();
    for (var i = zero.length; i < str.length; i++) {
        output.push(str.charCodeAt(i) - "A".charCodeAt(zero.length));
    }
    return output;
}

while(true) {
    alert(go());
}
})();

```

Fairly clear what it's doing, but just in case, we're using ASCII character codes to pull back the numbers, starting at A (char code 65), just because A is nice and has no numerical connotations. First answer. Be gentle. :)

# Answer
> 2 votes
# Java

I was inspired from the sample of how not to do it.

```
class TheNumbers
{
    public static void main(String[] args) {

    int FOUR = 9+9-7-7;
    int EIGHT = 9+9-7-7 + 9+9-7-7;
    int FIFTEEN = (9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9 - 7)/(9-7);
    int SIXTEEN = 9+9-7-7+9+9-7-7 + 9+9-7-7+9+9-7-7;
    int TWENTY_THREE = (9+9-7-7+9+9-7-7 + 9+9-7-7+9+9-7-7 +  9+9-7-7+9+9-7-7 + 9+9-7-7+9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9-7 + 9-7+ 9-7)/(9-7);
    int FOURTY_TWO =  9+9-7-7+9+9-7-7 + 9+9-7-7+9+9-7-7 +  9+9-7-7+9+9-7-7 + 9+9-7-7+9+9-7-7 + 9+9-7-7 + 9+9-7-7 + 9-7;

    for(int n = 0;;) System.out.println(
        n == FOUR ? n = EIGHT :
        n == EIGHT ? n = FIFTEEN :
        n == FIFTEEN ? n = SIXTEEN :
        n == SIXTEEN ? n = TWENTY_THREE :
        n == TWENTY_THREE ? n = FOURTY_TWO : (n = FOUR)
        );
    }
}

```

Edited so that I do not use the numbers 1,2,3,4,5,6,8,0 anywhere. I originally had things like 14+1 to avoid using 15, but there is a 1 and a 4 that I am not allowed to use.

Sweet, I got upvotes?! I thought this would be ignored or even possibly downvoted xD \<3

# Answer
> 2 votes
# Python

```
while 1:print ' '.join([`int(3*5+57*x/20-31*x*x/2**3+11*x**3/2**3+7*x*x**3/2**3-9*x**5/(2**3*5))` for x in [-2.,-1,0,1.,2,3]]),

```

Interpolation over the sequence -2..3

# Answer
> 2 votes
# Delphi

I chose to use primes to solve this.
First selected all primes \< 55 and did some calculations with that.

```
uses
  System.sysutils,Generics.Collections;

  function ESieve(upperLimit:integer):TList<integer>;
  var
    i,j: integer;
    a:array of boolean;
    upperSqrt,sieveBound:integer;
  begin
    Result:=TList<integer>.Create;
    sieveBound:=Round((upperLimit-1)/2);
    upperSqrt:=Round((Sqrt(upperLimit)-1)/2);
    SetLength(a,sieveBound);
    for I:=0to sieveBound-1 do
      a[I]:=true;
    for I:=1to upperSqrt do
    begin
      if a[I] then
      begin
        J:=i*2*(i+1);
        while J<=sieveBound do
        begin
          a[J]:=false;
          J:=J+2*i+1;
        end
      end
    end;
    Result.Add(2);
    for I:=1to sieveBound-1do
      if a[i]then
        Result.Add(2*i+1);
  end;
var
  a,primes:TList<integer>;
  i:integer;
begin
  i:=1;
  primes:=ESieve(55);
  a:=TList<integer>.create;
  i:=i+3;
  a.Add(primes[i]-primes[i-1]);
  a.Add(primes[2]+primes[1]);
  a.Add(primes[i+1]+primes[0]);
  a.Add(a[a.Count-1]+1);
  a.Add((primes[1]*primes[3])+primes[0]);
  a.Add((a[a.Count-1]*2)-a[0]);

  while 1>0 do
  begin
    for I := 0 to a.Count-1 do
      write(Format('%d ',[a[i]]));
    write(#13#10);
    sleep(200);
  end;
end.

```

# Answer
> 2 votes
## Java

I tried to golf/obfuscate it a little - as you can see I didn't try super hard. The program looks a lot better than the LICEcap gif.

```
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.imageio.*;
import javax.swing.*;

public class N extends JFrame implements ActionListener {
    public static void main(String[] args) throws Exception {
        i=new ImageIcon(ImageIO.read(new URL("http://i.imgur.com/oMloP1J.jpg")));
        EventQueue.invokeLater(new Runnable() {public void run() {new N().setVisible(true);}});
    }
    static ImageIcon i;
    JPanel c;
    Rectangle r;
    public N() {
        JLabel a=new JLabel(i);
        JLabel b=new JLabel(i);
        c=new JPanel();
        c.setLayout(new BoxLayout(c,1));
        c.add(a);
        c.add(b);
        JScrollPane j=new JScrollPane(c,21,31);
        Dimension d=j.getPreferredSize();
        d.setSize(d.width,d.height/2+1);
        j.setPreferredSize(d);
        r=new Rectangle(d);
        JPanel t=new JPanel();
        t.add(j);
        setContentPane(t);
        setResizable(false);
        pack();
        setDefaultCloseOperation(3);
        new Timer(20,this).start();
    }
    public void actionPerformed(ActionEvent e) {
        r.translate(0,1);
        if(r.getY()==r.height)r.translate(0,-r.height);
        c.scrollRectToVisible(r);
    }
}

```

# Answer
> 2 votes
## C#

```
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = "ruLOST";
            var b = "nm=?<*";
            var i = 0;
            while (true)
            {
                Console.WriteLine(a[i] - b[i]);
                if (++i > 5) i = 0;
            }
        }
    }
}

```

# Answer
> 2 votes
# Java 7

Being old-school this is a real tree-shredder: (Tested against PDF-printer; respects page-ranges in regards of page-count)

```
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.swing.*;
import java.awt.*;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

public class Sequence {
    public static void main(String[] args) {
        // initialize numbers
        long z = 12731310;
        for (long l = 1; l <= 9 * 17 * 263 * 1021; l++) {
            z += l;
        }
        long n = 9;
        for (int i = 0; i < 5; i++) {
            n *= 729;
        }
        n--;
        // Get into printing. Use the cross-platform dialog as it also asks for paper
        systemLookAndFeel();
        final PrinterJob printerJob = PrinterJob.getPrinterJob();
        printerJob.setJobName("Tree Shredder");
        printerJob.setPrintable(new PrintableSequence(z, n));
        final HashPrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
        if (printerJob.printDialog(attributeSet)) {
            try {
                printerJob.print(attributeSet);
            } catch (PrinterException e) {
                e.printStackTrace();
            }
        }
    }

    private static void systemLookAndFeel() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
            // this should only happen if UIManager.getSystemLookAndFeelClassName() is broken
            e.printStackTrace();
        }
    }

    private static class PrintableSequence implements Printable {

        private       long z;
        private final long n;
        private       int  lastPage = -1;
        private       long lastZ;

        public PrintableSequence(long z, long n) {
            this.z = z;
            this.n = n;
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
            // First call ist just to check that the page exists and we need to produce the same page again
            if (pageIndex != lastPage) {
                lastPage = pageIndex;
                lastZ = z;
            } else {
                z = lastZ;
            }
            final FontMetrics fontMetrics = graphics.getFontMetrics();
            final double imageableWidth = pageFormat.getImageableWidth();

            graphics.translate((int) pageFormat.getImageableX(), (int) pageFormat.getImageableY());

            for (int y = fontMetrics.getMaxAscent();
                 y < pageFormat.getImageableHeight(); y += fontMetrics.getHeight() * 1.2) {
                for (int x = 0; x < imageableWidth; ) {
                    z = (z % n) * 9;
                    final char c = Character.forDigit((int) (z / n), 9);
                    final String s = c == '0' ? ", " : String.valueOf(c);
                    final double width = fontMetrics.getStringBounds(s, graphics).getWidth();
                    if (x + width > imageableWidth) {
                        z /= 9;
                        break;
                    }
                    graphics.drawString(s, (int) x, (int) y);
                    x += width;
                }
            }
            return PAGE_EXISTS;
        }
    }
}

```

The sequence is generated as in Implement arbitrary precision division.

# Answer
> 2 votes
## C#

By using 7 that is allowed by question, start everything of wordcount from "0000"

```
int four ="0000".Length;
int eight = four + four;
int fifteen = eight + 7;
int sixteen = eight + eight;
int twentythree = sixteen + 7;
int fourtytwo = four + fifteen + twentythree;
List<int> list = new List<int> { four, eight, fifteen, sixteen, twentythree, fourtytwo };

//while (true) //for (; ;)
//{
//    foreach (int number in list)
//    {
//        Console.WriteLine(number);
//    }
//}

//infinite loop via number 0,7,9 that are allowed
//for (int i=0; i<7; i++)
//{
//    Console.WriteLine(list[i]);
//    if (i == (7-9+7))
//        i = 0;
//}

for (int i=0;;i++)
{
    Console.WriteLine(list[i]);
    i = i % (7-9+7);
}

```

# Answer
> 2 votes
C#

```
using System;

class Numbers
{
    const string s = "I have to be honest with you, this question turned "
                   + "out to be harder than I expected. I didn't want to "
                   + "use characters, because I think it is a really     "
                   + "lame way to 'solve' the challenge, but meh.        "
                   + "Guess I'm not as smart as I thought. I tried to    "
                   + "do it with a polynomial, but it's pretty much      "
                   + "impossible to write down the coefficients without  "
                   + "breaking one of the rules. Unless, of course, you  "
                   + "use characters, but that kinda defeats the purpose "
                   + "of the whole polynomial thing. Now, lets insert    "
                   + "some random characters, just for fun!              "
                   + "(I can hear you think 'yeah, right...')            "
                   + "BTW, I have tons of respect for you if you can do  "
                   + "this without the weird stuff at the end!           "
                   + "7`ypg6";

    static void Main(string[] args)
    {
        char b = '\0';
        for (int i = 0; ; i = ++i % 6, b = '\0')
        {
            for (int j = i; j < s.Length; j += 6) b ^= s[j];
            Console.WriteLine((int)b);
        }
    }
}

```

Not too compact, or hard to figure out, I guess.

> The 'random' characters at the end make sure that if you XOR all every nth (n = 1 to 6) character in that long text, you end u with the right number in the sequence

# Answer
> 2 votes
# Coffeescript, 142B

```
f = (x) -> Math.round(3+1-223*x/20+(2*13.1375+0.6)*x*x-2*7.3125*x*x*x+3.125*x*x*x*x-0.225*x*x*x*x*x)
document.body.append ' '+f(i%6) while i++

```

Solve a system of linear equations, echo result.

# Answer
> 2 votes
**PHP**

strtotime capabilities

```
echo date('n', strtotime('april')) .', ';
echo date('n', strtotime('august')) .', ';
echo date('n', strtotime('january')) . date('n', strtotime('may')).', ';
echo date('n', strtotime('january')) . date('n', strtotime('june')).', ';
echo date('n', strtotime('february')) . date('n', strtotime('march')).', ';
echo date('n', strtotime('april')) .date('n', strtotime('february'));

```

# Answer
> 2 votes
Just:

```
while(1) document.write(parseInt(Math.random()*50));

```

There's a little noise, but that's contest OK.

# Answer
> 2 votes
# PHP

```
<?php
    $x = crc32("KLEJl");
    $y = intval(dechex(ord(" ")) . ord("$"). ord("\t"));

    $r = false;
    for (;;) {
        $a = str_split(strval($x));
        $x ^= $y;
        foreach($a as $i => $c) {
            echo $c;
            if ($r || !$i) {
                echo "\n";
            }
            $r = !$r;
        }
    }

```

# Answer
> 2 votes
# Ruby

```
def seq_for(n)

  seq = [n*n, n*n*n, n*n*n*n, n*n*n*n, "#{n}#{-~n}", "#{n*n}#{n}"]

  seq[n]-=~-n

  seq.join(''<<(n + seq.last.to_i))

end

loop do
  n=-~(rand $$)
  puts(seq_for(n+n)) rescue n
end

```

No numbers in any base in the code, just a method that will output The Numbers if given a certain argument, and will error out for almost any other input. With the loop wrapper this will just output The Numbers at random intervals. Incidentally, the wrapper prevents this from happening, but with other input seq\_for can produce

```
10000100

```

or

```
1
 1
  1
   1
    12
      11

```

or

```
9`27`81`79`34`93

```

# Answer
> 2 votes
So print `4, 8, 15, 16, 23, 42` without using the actual numbers in the code.
Not the best looking solution, but it is definitly the easiest

> 2 * 2 = 4
> 4 * 2 = 8
> 8 * 2 - 1 = 15
> 15 + 1 = 16
> 16 + 7 = 23
> 23 + 19 = 42

```
<?php

while (true) {
    $nr = 2 * 2;        // 4
    echo $nr;
    $nr = $nr * 2;      // 8
    echo $nr;
    $nr = $nr * 2 - 1;  // 15
    echo $nr;
    $nr = $nr + 1       // 16
    echo $nr;
    $nr = $nr + 7       // 23
    echo $nr;
    $nr = $nr + 19      // 42
    echo $nr;
    echo PHP_EOL;
}

?>

```

# Answer
> 2 votes
## Python

I found a quintic polynomial that goes through the numbers at x from 1 to 6:

-0.225x<sup>5</sup> \+ 4.25x<sup>4</sup> \- 29.375x<sup>3</sup> \+ 91.75x<sup>2</sup> \- 122.4x + 60

So here's my Python solution:

```
for x in range(1,6):print -0.225*x**5+2*2.125*x**(2+2)-29.375*x**3+91.75*x**2-2*61.2*x+60

```

I know it isn't the shortest and it uses numbers, but I like it because it uses a generating function.

# Answer
> 2 votes
## C

Not very creative, I'm afraid.

```
char*p="DHOPWj";main(){for(;;)!*p?p-=6:printf("%d, ",*p++&63);}

```

# Answer
> 2 votes
# Java

```
class N {
    public static void main(String[] args) {
        while(true) {
            int n = " ".length();
            System.out.print(
                (++n + n) + " " +
                ((++n - n) + ++n + n) + " " +
                ((n * n) - (n / n)) + " " +
                (n * n) + " " +
                ((n * n) + (n + n) - (n / n)) + " " +
                ((n * n * n)  - n * --n * --n + n) + "\n"
            );
        }
    }
}

```

Turned out to be rather simple.

# Answer
> 2 votes
**Javascript**

```
function f(a) {
var b=(a%6)-3;
return ((1 - ~~(((a%6)+1)/(1<<2))) * (Math.pow (2,((a%6)+2)) - (~~(((a%6)+1)/3))))  + (~~(((a%6)+1)/(1<<2))*((2<<3)+(2<<2)*b*b-Math.pow(6,b*(b-1)/2)*Math.round(b/2)))
}
for (i=0;;i=(i+1) % Math.pow (2,52))
   console.log (f (i))
}

```

Using this formula

The fomula basically does the following

```
function f(x) {
   var value = 0;
   x = 1 + (x % 0);
   if (x < 3)  {
       value += 2^(x+3);                                //0:4, 1:8, 2:16, 3:0, 4:0, 5:0
       if (x > 2) {
           value -= 1                                   //0:0, 1:0, 2:1, 3:0, 4:0, 5:0
       }
   } else {
      value += 16;                                      //0:0, 1:0, 2:0, 3:16, 4:16, 5:16
      value += 8 * (x-3)^2                              //0:0, 1:0, 2:0, 3:0, 4:8, 5:32
      value -= ( 6 ^ ((x-3) - (x-4))) * round ((x-3)/2) //0:0, 1:0, 2:0, 3:0, 4:1, 5:6
   }
   return value;
}

```

I don't know if that's the right way to construct a formula, but since i never studied math nor did something like this before, this was the only thing i could come up with. I was actually pretty surprised that you can give your algebra somewhat like a control flow. *<sub>Took me a while to figure this out though</sub>*

This is how it looks when you draw it <sub>It looks a lot less chaotic than i thought for not whole numbers </sub>

# Answer
> 2 votes
## Python

Using simple bitshifts and XOR's

```
#!/usr/bin/python
while True:
    print 1 << 1 << 1
    print 1 << 1 << 1 << 1
    print ( 1 << 1 << 1 << 1 << 1 ) ^ 0b11111
    print ( 1 << 1 << 1 << 1 << 1 )
    print ( 1 << 1 << 1 << 1 << 1 << 1 ) ^ 0b110111
    print ( 1 << 1 << 1 << 1 << 1 << 1 ) ^ 0b001010

```

# Answer
> 2 votes
# C++

Never said we couldn't just take two other numbers and add 'em!
EDIT: Forgot to cast the ints as strings, now the code is really ugly!

```
#include <iostream>
#include <sstream>

int main () {
     std::ostringstream convert1;
     std::ostringstream convert2;
     std::ostringstream convert3;
     std::ostringstream convert4;
     std::ostringstream convert5;
     std::ostringstream convert6;
     int fourint = 1 + 3;
     convert1 << fourint;
     std::string four = convert1.str();
     int eightint = 1 + 7;
     convert2 << eightint;
     std::string eight = convert2.str();
     int fifteenint = 2 + 13;
     convert3 << fifteenint;
     std::string fifteen = convert3.str();
     int sixteenint = 3 + 13;
     convert4 << sixteenint;
     std::string sixteen = convert4.str();
     int twentythreeint = 1 + 22;
     convert5 << twentythreeint;
     std::string twentythree = convert5.str();
     int fortytwoint = 21 * 2;
     convert6 << fortytwoint;
     std::string fortytwo = convert6.str();
     while (1) {
          std::cout << "\n" + four + " " + eight + " " + fifteen + " " + sixteen + " " + twentythree + " " + fortytwo;
     }
}

```

# Answer
> 2 votes
**JavaScript**

```
while(1)[1,5,12,13,20,39].map(function(n){console.log(n+3)})

```

Okay, that's basically hard-coding the numbers. How about:

```
while(1)[].map.call('DHOPWj',function(n){console.log(n.charCodeAt()&63)})

```

or a shorter version of that one:

```
for(i=0;;i=++i%6)console.log('DHOPWj'.charCodeAt(i)&63)

```

# Answer
> 2 votes
**PHP**

I took "You may not use the numeral 4" and 8 to mean anywhere in the code and went for an ultra simple mathematical solution...

```
while (1) {
    $x = 3;
    echo ++$x . ',';
    echo $x*=2 , ',';
    echo floor($x*=1.9) , ',';
    echo floor($x*=1.1) , ',';
    echo ceil($x*=1.35) , ',';
    echo floor($x*=1.9) , ',';
}

```

# Answer
> 2 votes
**Python**

```
while True:
    d = 57173610360
    while d:
        d,m = divmod(d, 67)
        print(m)

4
8
15
16
23
42
...

```

Constants found from the following:

```
>>> s, v = (4, 8, 15, 16, 23, 42), []
>>> for j in range(max(s)+1,101):
    sm = str(sum(n*j**i for i,n in enumerate(s)))
    if not any(x in sm for x in (str(y) for y in s)):
        v.append((j, sm))

>>> v
[(67, '57173610360')]
>>>

```

# Answer
> 2 votes
**C#**

Uses a single constant, 2:

```
using System;

namespace Seq
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = 2;
            var b = a;

            while (true)
            {
                a *= b;
                var x = a;
                Console.Write(" " + a);
                a *= b;
                var y = a;
                Console.Write(" " + a);
                a *= b;
                b = b / b;
                a = a - b;
                var z = a;
                Console.Write(" " + a);
                a = a + b;
                var w = a;
                Console.Write(" " + a);
                a = y + z;
                Console.Write(" " + a);
                a = x + y + z + w - b;
                Console.Write(" " + a);

                a = b + b;
                b = a;

                Console.ReadLine();
            }
        }
    }
}

```

# Answer
> 1 votes
# Python

```
def main():
    a = range(3+1)
    b = range(7+1)
    c = range(3*5)
    d = range(13+3)
    e = range(20+3)
    f = range(6*7)
    All = [a,b,c,d,e,f]
    while True:
        for n in All:
            print(len(n))
main()

```

# Answer
> 1 votes
# C

A few (implementation dependent) ideas:

## 1

```
main()
{
    char a[] = "uKyKrvKrwKstKusK";
    unsigned int i;

    for(i = 0; i >= 0; i++)
    {
        printf("%c", (char)(a[i&(sizeof(a)-2)] - 'A'));
    }
}

```

## 2

```
#include <stdio.h>
#include <string.h>
#include <float.h>

#define Answer_to_the_Ultimate_Question_of_Life_The_Universe_and_Everything  I_may_be_a_sorry_case_but_I_dont_write_jokes_in_base_13(Six by nine)
#define Six 0b110
#define by *
#define nine 0b1001
#define I_may_be_a_sorry_case_but_I_dont_write_jokes_in_base_13(x) 10*(x/13)+x%13

void PrintNumSequence(void);

int main(void)
{
    PrintNumSequence();
}

/*
Prints out the following sequence forever: http://lostpedia.wikia.com/wiki/The_Numbers
*/
void PrintNumSequence(void)
{
    int a[] = {sizeof(int), sizeof(double), DBL_DIG, strlen(__func__), __LINE__, Answer_to_the_Ultimate_Question_of_Life_The_Universe_and_Everything};
    unsigned int i;

    while(1)
    {
        for(i = 0; i < sizeof(a)/sizeof(a[0]); i++)
        {
            printf("%d \n", a[i]);
        }
    }
}

```

# Answer
> 1 votes
# C++

```
#include<iostream>
int main()
{
    for(;;)
        std::cout<<'\n'-6<<", "<<'\n'-2<<", "<<'\n'+5<<", "<<'\n'+6<<", "<<' '-9<<", "<<'*'+0<<", ";
}

```

# Answer
> 1 votes
The following snippets will print `4, 8, 15, 16, 23, 42` infinitely often:

## Python

### OASIS

```
import urllib2
response = urllib2.urlopen('https://oeis.org/search?q=id:A104101&fmt=text')
html = response.read().split("\n")
while True:
    print(html[6][-15:])

```

### Char-Codes:

```
four = ord('')
eight = ord("\n")-2
fifteen = ord("\n")+5
sixteen = ord("")
twentythree = ord("")
theanswer = ord("*")
numbers = "%s, %s, %s, %s, %s, %s" % (four, eight, fifteen, sixteen, twentythree, theanswer)
while True:
    print(numbers)

```

## Substring of Pi

Pi contains 481516234 at position 176,025,488 (source). One could use that.

# Answer
> 1 votes
# **C**

Here is an Ungolfed version using C. If you get too many initializations error, just initiate a\[4\] and a\[5\] seperately and it will do it.

```
#include<stdio.h>
main()
{
    char i,j,a[5] = {'Z'-'V','Z'-'R','Z'-'K','Z'-'J','Z'-'C','*'};
    for(i='Z';'a';i++) {
        for(j='Z'-'Z';j<='Z'-'U';j++) {
            printf("%d\n",a[j]);
        }
    }
}

```

Here's a Golfed Version:

```
#include<stdio.h>
main(){char i,j,a[5] = {'Z'-'V','Z'-'R','Z'-'K','Z'-'J','Z'-'C','*'};for(i='Z';'a';i++)for(j='Z'-'Z';j<='Z'-'U';j++)printf("%d\n",a[j]);}

```

# Answer
> 1 votes
# Python 2.7:

```
>>> a=len("four")
>>> b=a+a
>>> d=b+b
>>> c=d-(d/d)
>>> e=b+c
>>> f=b/a*e-d/a
>>> while a: print " ".join([str(i) for i in [a,b,c,d,e,f]]),

```

Pretty straightforward I'd say.

# Answer
> 1 votes
# Python3

Here's another piece. My first try was improved by canaaerus (the final part of the code below is adapted from there), and now I'm using the following sequences to create the desired one: A075105, A070750 and A122115.

```
from math import floor, log, pi, sin
from fractions import Fraction

def log2(x):
    return log(x) / log(2)

def isprime(n):
    for i in range(2, n):
        if n % i == 0: return False
    return True

v = [ Fraction(n,floor(log2(n))).numerator for n in range(5,10) ]
p = filter(isprime,range(7,20))
s = [ sin(k*pi/2) for k in p ]
x = [ floor(a*b) for a,b in zip(s,v) ]

while x[-1] != 66:
    x.append(x[-5] + x[-3] + x[-1])

while True:
    print(x[-7:-1])

```

# Answer
> 1 votes
# C

```
main()
{
    int num;

    for (num=1;;num=1) {
        printf("%d\n", num<<=2);
        printf("%d\n", num<<=1);
        printf("%d\n", num|7);
        printf("%d\n", num<<=1);
        printf("%d\n", num|7);
        printf("%d\n", num<<1|num>>1|1<<1);
    }
}

```

# Answer
> 1 votes
## JavaScript

```
      var four = 3+1;
      var eight=7+1;
      var fifteen = 13+2;
      var sixteen = 13+3;
      var twentythree = 22+1;
      var fortytwo = 39+3;

while(true){
      var sequence = four  + ", " + eight+ ", " + fifteen  + ", " +
                     sixteen  + ", " +     twentythree  + ", " + fortytwo ;
       console.log(sequence);
}

```

Kinda ridiculously easy task, unless I'm missing something...

# Answer
> 1 votes
**PHP**

```
<?php
$a[]=2;
$a[]=$a[0]*$a[0];
$a[]=$a[1]*$a[0];
$a[]=$a[2]*$a[0]-1;
$a[]=$a[2]*$a[0];
$a[]=strrev($a[$a[0]+$a[0]]*$a[0]);
$a[]=$a[0]*21;
unset($a[0]);

while(1){
  foreach($a as $b){
   echo $b.' ';
  }
  //optional for formatting
  echo "<br>\n";
}
?>

```

**Slight Modification**

```
<?php
$a[]=2;
$a[]=$a[0]*$a[0];
$a[]=$a[1]*$a[0];
$a[]=$a[2]*$a[0]-1;
$a[]=$a[2]*$a[0];
$a[]=strrev($a[$a[0]+$a[0]]*$a[0]);
$a[]=$a[0]*21;
unset($a[0]);

while($a){
  $b=array_reverse($a);
  while($b){
    echo array_pop($b).' ';
  }
//optional for formatting
echo "<br>\n";
}

```

# Answer
> 1 votes
## Haskell

```
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit (simpleHttp)
import Data.ByteString.Lazy.Char8 (ByteString, unpack)

import Data.List
import Data.Maybe

url="http://bit.ly/Oijgr0"

parseSequence::ByteString->[Int]
parseSequence i = parser $ text i
    where
        text = (drop 9) . head . catMaybes . (map $ stripPrefix "%S") . lines . unpack
        parser = (map read) . (split ',')
        split _ []=[[]]
        split n (x:xs) | n==x = []:(split n xs)
                       | otherwise = let (l:ls)=split n xs in (x:l):ls

main=print =<< (fmap (cycle . parseSequence) $ simpleHttp url)

```

Apparently it is oeis.org/A104101 (I have to use the shortened link because the sequence name has a 4 in it.)

# Answer
> 1 votes
# Forth (gforth)

So here's my solution. It pushes a 2 (on the stack) and then modifies the stack.

**Short** version:

```
: x
  begin
    2 2 * dup .
    2 * dup .
    dup 2 * 1 - .
    dup 2 * dup .
    + 1 - dup .
    2 * 2 2 * - .
    cr
  0 until
;

x

```

**Minified short** version (**100** Chars):

```
: x begin 2 2 * dup . 2 * dup . dup 2 * 1 - . dup 2 * dup . + 1 - dup . 2 * 2 2 * - . cr 0 until ; x

```

**Readable long** version with comments:

```
: one 1 ;
: two 2 ;
: add + ;
: sub - ;
: mul * ;
: inc one add ;
: dec one sub ;
: dbl two mul ;

: out
    begin
        two dbl dup     . ( output:  4, stack:  4 )
        dbl dup         . ( output:  8, stack:  8 )
        dup dbl dec     . ( output: 15, stack:  8 )
        dup dbl dup     . ( output: 16, stack:  8 16 )
        add dec dup     . ( output: 23, stack: 23 )
        dbl two dbl sub . ( output: 42, stack: <empty> )
        cr
    0 until
;

out

```

# Answer
> 1 votes
# **JAVASCRIPT**

```
function printInt(){
var someJavaCode = "roll {Drums;} while(rollDrum) {Drums.plays();} if(Drums.playingNow()){ displayThisToDoc(aGuyPlayingDrumPicture);}"
var brokenPiece = someJavaCode.split(' ');
var returnVal = [];
for(var i=0;i< brokenPiece.length;++i){
returnVal.push(brokenPiece[i].length);
}
return returnVal;
}
printInt();

```

# Answer
> 1 votes
## Python 3

```
x=list(str(int(33706136394/7)))
while 1:print(x[0],x[1],x[2]+x[3],x[3+1]+x[5],x[6]+x[7],x[7+1]+x[9])

```

# Answer
> 1 votes
Haskell, phoning it in.

```
main = putStrLn $ show $ cycle $ map (+3) [1, 5, 12, 13, 20, 39]

```

# Answer
> 1 votes
# C

NOTE: Not a single digit actually used in the code.

```
#include <stdio.h>

#define s (':')
#define m (s - ';')
#define l ('@' - s)
#define c (">BIJQd")

main()
{
    char a[l] = c;
    char i = m;
    while(l) printf("%d, ", a[i = (++ i) % l] - s);
}

```

# Answer
> 1 votes
## C#

```
void Main()
{
    while (true)
        foreach (var c in "EIPQXk")
            Console.Write(c - 'A');
}

```

Edit: figured.. why not use linq too. Here you can optionally also have a newline at the end of every sequence without adding more than the work `Line`.

```
while (true)
    Console.Write(String.Concat("EIPQXk".Select(c => c - 'A')));

```

# Answer
> 1 votes
# Python

```
a = 1

while (a > 0):
    b = a + 3
    c = b * 2
    d = c + 7
    e = c * 2
    f = e + 7
    g = f + c + 11
    print b, c, d, e, f, g

```

It's not very "pythonic" but it has room for improvement

# Answer
> 1 votes
**COBOL**

```
   ID DIVISION.
   PROGRAM-ID. LOST.
   DATA DIVISION.
   WORKING-STORAGE SECTION.
   01  LOST PIC XXXX.
   LINKAGE SECTION.
   01  TOTALLY-LOST PIC 9,9,99,99,99,99.
   PROCEDURE DIVISION USING TOTALLY-LOST.

       COMPUTE TOTALLY-LOST =
                            (
                             (
                              FUNCTION LENGTH ( LOST )
                             )
                            *
                             1000000000
                            )
               +
                            (
                             (
                              FUNCTION LENGTH ( LOST )
                              +
                              FUNCTION LENGTH ( LOST )
                             )
                            *
                             100000000
                            )
               +
                            (
                             (
                              (
                               FUNCTION LENGTH ( LOST )
                               *
                               FUNCTION LENGTH ( LOST )
                              )
                              -
                              (
                               FUNCTION LENGTH ( LOST )
                               /
                               FUNCTION LENGTH ( LOST )
                              )
                             )
                            *
                             1000000
                            )
               +
                            (
                             (
                              FUNCTION LENGTH ( LOST )
                              *
                              FUNCTION LENGTH ( LOST )
                             )
                            *
                             10000
                            )
               +
                            (
                             (
                              (
                               FUNCTION LENGTH ( LOST )
                               +
                               FUNCTION LENGTH ( LOST )
                              )
                             +
                              (
                               (
                                FUNCTION LENGTH ( LOST )
                                *
                                FUNCTION LENGTH ( LOST )
                               )
                               -
                               (
                                FUNCTION LENGTH ( LOST )
                                /
                                FUNCTION LENGTH ( LOST )
                               )
                              )
                             )
                            *
                             100
                            )
               +
                            (
                             (
                              (
                               (
                                FUNCTION LENGTH ( LOST )
                                *
                                FUNCTION LENGTH ( LOST )
                               )
                               -
                               (
                                FUNCTION LENGTH ( LOST )
                                /
                                FUNCTION LENGTH ( LOST )
                               )
                              )
                             +
                              (
                               (
                                FUNCTION LENGTH ( LOST )
                                +
                                FUNCTION LENGTH ( LOST )
                               )
                              +
                               (
                                (
                                 FUNCTION LENGTH ( LOST )
                                 *
                                 FUNCTION LENGTH ( LOST )
                                )
                                -
                                (
                                 FUNCTION LENGTH ( LOST )
                                 /
                                 FUNCTION LENGTH ( LOST )
                                )
                               )
                              )
                             +
                              (
                               FUNCTION LENGTH ( LOST )
                              )
                             )
                            *
                             1
                            )

       GOBACK
       .

```

This is written as a sub-program to emphasise that the COMPUTE is both calculating and formatting the output. One Verb for that, one Verb to return from whence it came.

Which is here:

```
   ID DIVISION.
   PROGRAM-ID. CALLLOST.
   DATA DIVISION.
   WORKING-STORAGE SECTION.
   01  15-BYTE-LUMP                        PIC X(15).
   PROCEDURE DIVISION.
       CALL "LOST"                  USING 15-BYTE-LUMP
       DISPLAY
               15-BYTE-LUMP
       GOBACK
       .

```

Output, from the DISPLAY in the CAlling program, is:

```
4,8,15,16,23,42

```

In COBOL, there are no strings, just fixed-length fields. FUNCTION LENGTH or special register LENGTH OF give access to the length of the field (not the length of the content).

So, by calculating each of the elements using manipulations of the length of a four-byte field (content irrelevant), scaling each element (the last scaling is not required, but it seemed fun to leave it there) and using a numeric-edited PICture to format the total thus calculated, gives the required output.

The numeric-edited field just happens to be a re-mapping of storage area allocated in the CALLing program.

Note: The scaling could be done differently (no need ever to multiply/divide by a power of 10 unless for floating-point numbers, which already process slowly enough anyway) but then it could not be done in one instruction.

# Answer
> 1 votes
## C

My first answer on the site..

```
main(){for(1;;){printf("%d%d%d%d%d%d",2*2,5+3,3*5,9+7,18+5,21*2);}}

```

# Answer
> 1 votes
# F#

This solution references `HtmlAgilityPack`, a free and rather common library for parsing HTML.

```
[<EntryPoint>]
let main argv =
let web = HtmlAgilityPack.HtmlWeb()
let doc = web.Load("http://codegolf.stackexchange.com/search?q=The+definition+of+%22The+Numbers+may+not+appear+in+your+source+code%22+is+as+follows%3A")
let root = doc.DocumentNode
let node = root.SelectSingleNode("//div[@class='summary']/div[@class='result-link']/span/a")
let content = node.InnerText.Trim().Substring(3)
while true do
    printfn "%s" content
0

```

At first, I thought of just browsing to http: //codegolf.stackexchange.com/questions/23808, but that would involve having to type "23808", which contains the dreaded character '8'. This is what I did:

```
use client = new System.Net.WebClient()
let illegal_number = 30000 - 6192
let str = sprintf "http://codegolf.stackexchange.com/questions/%d/" illegal_number |> client.DownloadString
let regex = Regex.Match(str,"\<meta name=\"og:title\" content=\"([\d, ]*)\"")
let txt = regex.Groups.[1].Value
for i = 0 to 100 do
    printfn "%s" txt

```

Although this is a better in a way, since it doesn't require third party libraries, I felt the '3000-6192' deal was a bit cheap, so I came up with the above. Also, the other solution doesn't involve the evil of parsing HTML with regex.

# Answer
> 1 votes
# C

Can you figure out what is going on?

```
#include <inttypes.h>

main() {
    uint32_t*E=">=~",*D="0sek\r\360ww?";

    uint16_t i=atoi(D);
    double d=D[i]^D[!i];
    uint32_t*o=&d;
    uint8_t s=D[D&&D],m=D[E[!E&&o]&-E[!o&&E]],w=D[~i]&-D[~i];

    while(o)d=sin(d+i++),printf("%d\n",(*o>>s&m)-w);

    return 0;
}

```

The code has undefined behavior due to pointer-punning and accessing an array out of its bounds.

The code compiles (with some warnings) with gcc (no optimization), and produces the expected sequence on my computer (Windows 7).

### Spoilers

This is the original version of the code. The sequence is generated by taking 6 bits of the `double` numbers in the sequence generated by `d = sin(d + i)` where i increments from 0. The initial value is found by brute force.

```
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <inttypes.h>

int main(void) {
    double d = 470975293;
    uint32_t *o = (uint32_t*) &d;

    for (uint16_t i = 0; ; i++) {
        d = sin(d + i);
        printf("%d\n", (*o >> 13 & 0x3F) - 2);
    }

    return 0;
}

```

This version still has undefined behavior due to pointer-punning.

# Answer
> 1 votes
# Python3

Adding a somewhat boring no-digit answer to the mix.

```
while id:c,*s=b'JNRYZat';print(*[i-c for i in s])

```

# Answer
> 1 votes
# Javascript Console

I ran across this question and I was like, "hey, I wrote a program that outputs that sequence of numbers without The Numbers appearing in the source code anywhere that one time" And now, months later, I found the file I saved it in... The file was named `._. .js` because I'm so good at organization. I wrapped it in an interval.

```
setInterval(function(){var S=String, N=Number, s=Math.sqrt, n=function(a){console.log(a);return N(a)},
_={_:{_:document.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC/2}},twenty=N((_
/* THIS IS IMPORTANT: */ ._. /* DO NOT REMOVE.*/ _).toString(s(_
/* THIS IS IMPORTANT: */ ._. /* DO NOT REMOVE.*/ _))),_=_
/* THIS IS IMPORTANT: */ ._. /* DO NOT REMOVE.*/ _[S.fromCharCode(twenty+_
/* THIS IS IMPORTANT: */ ._. /* DO NOT REMOVE.*/ _)+S.fromCharCode(twenty+document.DOCUMENT_FRAGMENT_NODE)+S.name](),_=N(
/* THIS IS IMPORTANT: ⁎/ ._. /* DO NOT REMOVE.*/ _),$=n(2*n(s(_))),$=n(_-_/_),$=n(_+_+_
/* THIS IS IMPORTANT: */ -_- /* DO NOT REMOVE.*/ _),$=n(Array.prototype.slice.call(_+_+"").reverse().join("")),_=s(_+_+_
/* THIS IS IMPORTANT: */ -_- /* DO NOT REMOVE.*/ _)+_+_+_-(_.toString(_)),$=n(_+_+_
/* THIS IS IMPORTANT: */ -_- /* DO NOT REMOVE.*/ _);                                                                                n("The meaning of "+["life","the universe","and everything"].join(", ")+" is...    "
/* THIS IS IMPORTANT: */ +_+ /* DO NOT REMOVE.*/                                                                                ".")});;;
"kthxbai"

```

You can remove ⁎one⁎ of the faces that it iS IMPORTANT tHat you dON'T REMOVe.

# Answer
> 1 votes
# Marbelous

```
RR
:R
33
31
3035
3036
3735
33
QQ
:Q
}0
++20

```

RR references the board R, which doesn't have any input values and thus fires every tick. R has a bunch of ascii literals which it either throws onto the Q board or lets drop off the board. The Q board first prints a space and then the character the input value + 1 corresponds to. Throwing a value off the bottom of the board prints the corresponding ascii character.

# Answer
> 1 votes
## JavaScript

```
var numbers = (Math.pow(0.07697703609326959*99200,2)*6997299).toString().split('0')
var i = 0
setInterval(function(){
  document.getElementsByTagName('html')[0].innerHTML += numbers[i++%6]+' '
},50)

```

What I've done, is write a script that takes a number **`4`**`0`**`8`**`0`**`15`**`0`**`16`**`0`**`23`**`0`**`42`**. Since there are no `0`'s in the sequence of numbers, I could put one in between every digit as splitting point.

The script then loops through some processes to find numbers by which the number can be:

1. Divided
2. Square-rooted
3. Divided again

Without:

1. Generating any of the forbidden numbers
2. Creating a floating point issue

I simply took a random match from a whole list of matches, and there is my answer, simply put into a `setInterval`.

It splits the number at the `0`'s, and loops through them, pushing them into the DOM.

You can try it in this Fiddle.

I've also put my script in this Fiddle with which I've looked up my answer. It's also compatible with sequences that contain all of the 0 - 9 digits.

# Answer
> 0 votes
**VBA**

```
Sub chr_la_head_chr_la()
n = 50
Do While (True)
MsgBox Chr(n + 2) & " " & Chr(n + 6) & " " & Chr(n - 1) & Chr(n + 3) & " " & Chr(n - 1) & Chr(n + 3 + 1) & " " & Chr(n) & Chr(n + 1) & " " & Chr(n + 2) & Chr(n)
Loop
End Sub

```

# Answer
> 0 votes
## **Objective-C**

This is my first post on this forum, hopefully this code follows the rules:

```
int main(int argc, const char * argv[])
{
    @autoreleasepool {

        for (int i = 1; i < INFINITY; i++)   {
            int x = 2;

            int first = x + 2;
            int second = x + 6;
            int third = x + 13;
            int fourth = x + 7 + 7;
            int fifth = x + 21;
            int sixth = x + 10 + 30;

            NSLog(@"%i %i %i %i %i %i", first, second, third, fourth, fifth, sixth);
        }
    }
    return 0;
}

```

# Answer
> 0 votes
# C

How's this, haven't used any number.

```
int main() {

    int Four=2*2;
    int Eight=Four*2;
    int Fifteen=5*3;
    int Sixteen=Four*Four;
    int twenty3=fifteen+Eight;
    int fortytwo=21*2;
    printf("%d %d %d %d %d %d\n",Four,Eight,Fifteen,Sixteen,twenty3,fortytwo);

    main();
}

```

---
Tags: popularity-contest, number, sequence
---