# 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.

## closed as too broad by Alex A.Apr 23 '16 at 0:25

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

## locked by Alex A.Apr 23 '16 at 0:25

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.

• I can count 6 downvotes but no comments :/ – Vereos Mar 12 '14 at 13:52
• @Vereos, "This is a stupid question" isn't very constructive, which might be why no-one posted it as a comment. – Peter Taylor Mar 12 '14 at 15:26
• There are 11 types of people in this world: those that watched Lost, those that didn't, and those that don't understand binary. – squeamish ossifrage Mar 12 '14 at 16:26
• @PeterTaylor For sure, but newcomers mostly will not get that and leave the site instead of trying to improve their future questions. I guess that This isn't an interesting question, IMHO, since the solution is pretty trivial. Please post in the sandbox next time. would be way better than This is a stupid question., but that's just my personal opinion. – Vereos Mar 12 '14 at 16:57
• I notice the question does not prohibit outputting other numbers. So at least according to infinite-monkey-theory an unadulterated pseudo-random number generator should do the trick. – kojiro Mar 13 '14 at 13:21

# 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)
...

• This is great! I would not have thought of something like that. – Jordon Biondo Mar 12 '14 at 21:48
• Wow, beautiful ! Great idea ;) – Pierre Arlaud Mar 13 '14 at 8:25
• Genius! Though the output is a bit verbose, but I guess that has to do with the language you chose here. ;) – Pieter Witvoet Mar 13 '14 at 12:30
• Just when I thought the Python "lizt=Lost plot" one couldn't be topped... – Dave Mar 14 '14 at 14:27
• @justhalf Actually it bugs me this was the top answer for a little while there. It's no fun to win my own question. – Radiodef Mar 20 '14 at 6:59

## 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.

• So simple, and yet so good. – Konrad Borowski Mar 13 '14 at 13:22
• Whether or not this gets my vote depends entirely on the answer to this question: is the spelling of "lizt" an "Arzt" reference? EDIT: Who am I kidding, it gets my vote anyhow. – Plutor Mar 13 '14 at 14:11
• I would write while True: so that your answer contains no digits at all. – nneonneo Mar 14 '14 at 1:07
• while True: is more common. – Martin Ueding Mar 17 '14 at 14:09
• Doesn't that spoil the "no alternative bases" rule? Basically, it's just an array of base-1 numbers :-) – Daniel Mar 24 '14 at 22:15

# 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.

• I'm starting to look like this but I still don't see it.. – rdurand Mar 12 '14 at 16:55
• @xfix "This is a simple Perl program" - if that's the case, I'd hate to see a complicated one. – MikeTheLiar Mar 12 '14 at 19:24
• Hey look, it's a schooner. – roippi Mar 12 '14 at 20:31
• @roippi Haha, you dumb bastard. It's not a schooner, it's a SAILBOAT! – MikeTheLiar Mar 13 '14 at 14:52
• Protip: copy/paste to Notepad++ and zoom all the way out. – MikeTheLiar Mar 14 '14 at 18:59

## Brainfuck

I'm so bad at ASCII art !

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


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

• This is a really nice solution :) – gilbertohasnofb Mar 13 '14 at 15:14

## 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();
}

• The obfuscation here is pretty supreme for being simple substitution. – Radiodef Mar 13 '14 at 1:14
• Doesn't it run into stack overflow due to recursion? – Ski Mar 13 '14 at 16:52
• @Skirmantas I assume all compilers will use tail-recursion for this (eg. replace the call to main with a jump to main). – Tyilo Mar 13 '14 at 22:31

## 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)
{
}
}
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);
}
}
}
}

• +1 For someone that actually went to oeis.org in order to research a formula that fits the sequence :) – MrPaulch Mar 17 '14 at 6:57
• a(i)=a(i-1)+a(i-3)+a(i-5) really seems like an easier solution – Cruncher Mar 20 '14 at 20:40
• @Cruncher That formula requires you to predefine the first 5 terms (including 4, 8 and 15), which is both boring and against the rules. – Sebastian Negraszus Mar 20 '14 at 21:01

# 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.

• @kódfodrász thanks for the suggested edit! – Rik Mar 14 '14 at 11:44
• I see a numeral 8 in there, you bad person you – Thebluefish Mar 15 '14 at 14:20
• @Thebluefish I am ashamed. – Rik Mar 17 '14 at 8:11

## 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;
}
}

• ASCII arithmetic is best arithmetic. – Pharap Mar 15 '14 at 17:42
• So after C, came a language called D? – cegprakash Mar 20 '14 at 9:01
• @cegprakash And before C was B – SirPython Apr 9 '15 at 0:33

# Javascript + HTML

Anti-golf!

<!DOCTYPE html>
<html>
<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! • Plus one for ingenuity. Welcome to PPCG! – Jonathan Van Matre Mar 13 '14 at 23:27 # 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);}}  • As pretty as this may be, I count three 4s and two 8s in there. – Geobits Mar 13 '14 at 2:33 • @Geobits I obviously need a new pair of squinting goggles! Fixed now. – squeamish ossifrage Mar 13 '14 at 8:28 # 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"]]  • Well, that is one nice math solution. I really like this one – C5H8NNaO4 Mar 17 '14 at 17:59 • @C5H8NNaO4, Thanks, MSG. It was fun to figure out. – DavidC Mar 18 '14 at 1:26 • +1 You edited to get rid of the 16 in the fraction while I was typing a comment about it. – Geobits Mar 18 '14 at 1:27 • @Geobits. Funny about that. I thought I'd check whether I satisfied the rules; there were several violations that I since fixed. – DavidC Mar 18 '14 at 3:00 ## 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.

• I love the way Haskell and the like do functional programming :D – Jwosty Mar 12 '14 at 12:14
• fromEnum looks nicer than Data.Char.ord, and is somewhat shorter – mniip Mar 12 '14 at 13:43
• Whuh ... how? Could you explain? – Pureferret Mar 13 '14 at 14:57
• I just noticed the innocuous characters right at the end. I assume the have something to do with it? – Pureferret Mar 13 '14 at 17:01
• Ah. Yes, indeed, they do. – John Dvorak Mar 13 '14 at 17:20

# 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')   ;}


## 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();
}
}
}


# 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. • You can also pipe awk -F"[ ,]" '/%S/ {for (i=3;i<=9;i++) printf$i" "}' to curl. – fedorqui Mar 13 '14 at 13:18
• You can remove the loop altogether with yes and drop the redirect to /dev/null with curl -s. Something like yes $(curl -s "https://oeis.org/search?q=id:A$((130726+100))&t=text" | awk -F"[ ,]" '/%S/ {for (i=3;i<9;i++) printf $i" "}') – Digital Trauma Mar 14 '14 at 6:20 • @DigitalTrauma: Thanks, I did not know about yes and curl -s -- I just shamelessly added this to my answer. :-) – Heinzi Mar 14 '14 at 6:33 ## 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)))))); } }  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])  • very clever! Nice. – DavidC Mar 25 '14 at 12:26 # 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. # 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. # 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}  • All ruby code looks like it should just error and die; it shocks me to this day that any of it runs at all! – alexandercannon Mar 21 '14 at 15:35 # 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));}  • If you're golfing, you could (arguably) drop the a=0;. The only effect would be that you may start the sequence somewhere other than 4 (probably 8). Anyway, this will mess up the sequence when a overflows. It's technically undefined behavior, but the likely result is that you'll print garbage half the time. – jerry Mar 13 '14 at 17:25 • Or just cycle the string to "gAELMT" :) – orion Mar 13 '14 at 18:53 • Sure, unless someone invokes your program with arguments :) Still printing garbage half the time, though. – jerry Mar 14 '14 at 0:56 • If you give arguments to a program that doesn't need any, you pay the price :) – orion Mar 14 '14 at 9:42 • for doesn't help if there's no initialization. for(;;) is the same number of characters as while(). I interpreted the rules so that newlines have to be there... But I could use tail recursion with main... – orion Mar 20 '14 at 14:36 ## 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. • Welcome to the site =) – Riot Mar 16 '14 at 9:28 # 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. • There are 4s and 8s inside. – zakk Mar 14 '14 at 11:31 # 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.) • Easy to fix, but you still have a 4 in polynomial. – Geobits Mar 13 '14 at 2:28 • @Geobits whoops, didn't notice that. Thanks. – Andrew Soutar Mar 13 '14 at 2:45 ## 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. # 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  ## 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; } }  ## 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))))  • Welcome to the site =) – Riot Mar 16 '14 at 9:27 • +1 for "it requires a scheme implementation with infinite-accuracy support for quadratic irrationals, which (AFAIK) doesn't exist." – Lyndon White Mar 18 '14 at 11:21 ## 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 # 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;
}