4, 8, 15, 16, 23, 42

90

24

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.

Radiodef

Posted 2014-03-12T04:58:13.953

Reputation: 2 414

Question was closed 2016-04-23T00:25:28.327

8I can count 6 downvotes but no comments :/ – Vereos – 2014-03-12T13:52:43.713

1“You may not use the numeral 1 followed by the numeral 5” – So “1_5” is valid? Because ruby and perl just interprets it as 15. – manatwork – 2014-03-12T13:57:06.017

2@Vereos I was just thinking the same thing (... and 8 answers). I don't think the question is great, but I gave an upvote (and a comment) to even it out a bit. – daniero – 2014-03-12T13:59:02.030

1"Should I post these suggestions?" If you are changing the rules of the contest, no. If you just want to provide some ideas to get people to try approaching the challenge differently, go for it! Also, bear in mind there are no bonuses in a popularity contest...the votes reign supreme. – Jonathan Van Matre – 2014-03-12T14:01:22.313

This might have been funny as code-golf... – V-X – 2014-03-12T14:30:11.087

11@Vereos, "This is a stupid question" isn't very constructive, which might be why no-one posted it as a comment. – Peter Taylor – 2014-03-12T15:26:37.037

18

There are 11 types of people in this world: those that watched Lost, those that didn't, and those that don't understand binary.

– r3mainer – 2014-03-12T16:26:35.857

7@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 – 2014-03-12T16:57:25.190

2

@Vereos 'Pretty trivial to solve' isn't even particularly constructive considering that many popularity contests are trivial to solve and the point is not to do the bare minimum.

– Radiodef – 2014-03-12T17:29:19.777

@manatwork That's a good point, I forgot about underscores. Not sure if I should edit the OP. I thought about loopholes like this but ultimately figured that answers that take advantage of loopholes would be unpopular so it didn't make much of a difference. – Radiodef – 2014-03-12T17:31:54.040

@Radiodef The point of my sentence was not that; I just wanted to enhance the fact that in my opinion a downvote should always be paired to a (more or less) kind comment. – Vereos – 2014-03-12T17:48:11.787

@Vereos I get what you meant, I am just saying I still don't understand where the down votes came from. – Radiodef – 2014-03-12T17:55:34.267

@Radiodef aha I see what you did there... haven't seen Lost in quite some time! – CompuChip – 2014-03-12T18:01:06.780

When I saw the edit that added a link to "fix a pseudo-random generator", I thought it would point to my answer below. Instead it links to a page on SO :(

– Geobits – 2014-03-12T18:13:22.673

@Geobits I didn't see you had actually already done it until after the edit but you got an up vote from me since it was a thing I had in mind. : ) I tried to find a seed myself but wasn't able to. – Radiodef – 2014-03-12T18:16:50.593

1You just didn't look far enough. It's around 8.45e9 ;) – Geobits – 2014-03-12T18:19:21.837

1

Some formulas are available at OEIS. a(i)=a(i-1)+a(i-3)+a(i-5) seems like it could help.

– Ypnypn – 2014-03-12T19:53:56.077

Thou shall not count to two, unless they proceed to three! :) – user1853181 – 2014-03-13T09:19:35.030

3I 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 – 2014-03-13T13:21:59.987

const int four = 1+1+1+1; – Spook – 2014-03-14T12:14:04.230

@kojiro I left it open to interpretation so I suppose that would be a valid entry. "Outputs infinitely" implies you have infinite time to output them. But it would be difficult to demonstrate it works and unfiltered output wouldn't be obvious on its own. – Radiodef – 2014-03-14T18:27:29.130

1@squeamishossifrage Haven't watched lost, understand binary. Uh oh! – George Reith – 2014-03-15T12:34:23.180

Out of curiosity - what is the background for this particular sequence? – Thorbjørn Ravn Andersen – 2014-03-17T12:01:57.380

1@ThorbjørnRavnAndersen The numbers appear in the television show Lost. There is actually not really a whole lot more to it than that. They are a plot device and part of the lore. – Radiodef – 2014-03-18T16:31:11.793

1PHP (80chr) $i=2;while($i){$i=$i%9==6?4:$i<<1;if($i%9==7)echo $i-1,$i,2+$i+=5;else echo $i;} can't post answer??? – CSᵠ – 2014-03-27T16:42:57.090

Answers

232

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

Radiodef

Posted 2014-03-12T04:58:13.953

Reputation: 2 414

17This is great! I would not have thought of something like that. – Jordon Biondo – 2014-03-12T21:48:26.507

2Wow, beautiful ! Great idea ;) – Pierre Arlaud – 2014-03-13T08:25:38.530

5Genius! Though the output is a bit verbose, but I guess that has to do with the language you chose here. ;) – Pieter Witvoet – 2014-03-13T12:30:39.080

Brilliantly done! – Michaël Demey – 2014-03-13T14:54:08.457

3Just when I thought the Python "lizt=Lost plot" one couldn't be topped... – Dave – 2014-03-14T14:27:55.030

this really deserves to be the top answer – Joshua – 2014-03-18T10:17:12.047

I retracted my vote as I noticed the answer came from OP. What a way to brag. (This happens many times in PCG, though, indeed this site is a very suitable place to brag, haha) – justhalf – 2014-03-20T06:58:00.770

3@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 – 2014-03-20T06:59:39.937

I helped you to be the second! I believe you got the code first before constructing this challenge based on the unexpected output of your code? – justhalf – 2014-03-20T07:04:26.673

1@justhalf It seems it was for naught. The votes just keep coming! Also, if you are asking if I came up with this code by accident: no. I had the idea for this after I posted the challenge. I think my head would explode if I saw this in a legit stack trace. : ) – Radiodef – 2014-03-20T17:03:59.287

Loved this one! :) – None – 2014-03-22T11:41:42.740

183

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.

Kevin

Posted 2014-03-12T04:58:13.953

Reputation: 3 123

2So simple, and yet so good. – Konrad Borowski – 2014-03-13T13:22:14.720

4Whether 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 – 2014-03-13T14:11:48.257

6I would write while True: so that your answer contains no digits at all. – nneonneo – 2014-03-14T01:07:01.817

2while True: is more common. – Martin Ueding – 2014-03-17T14:09:07.157

1Doesn't that spoil the "no alternative bases" rule? Basically, it's just an array of base-1 numbers :-) – Daniel – 2014-03-24T22:15:51.577

77

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.

Konrad Borowski

Posted 2014-03-12T04:58:13.953

Reputation: 11 185

9

I'm starting to look like this but I still don't see it..

– rdurand – 2014-03-12T16:55:44.940

2A basic explanation for us mere mortals? – MikeTheLiar – 2014-03-12T18:53:44.263

1I think the numbers are in the whitespace. Ow. – Allen Gould – 2014-03-12T18:59:18.310

@mikeTheLiar: Sure. I decided to make a short explanation. This is actually quite simple (made of just two parts), but I guess that it should have an explanation anyway. It's in spoilers, to not spoil the code. – Konrad Borowski – 2014-03-12T19:02:10.073

69@xfix "This is a simple Perl program" - if that's the case, I'd hate to see a complicated one. – MikeTheLiar – 2014-03-12T19:24:29.370

8Hey look, it's a schooner. – roippi – 2014-03-12T20:31:13.370

1If you copy & pasted this and ran this to check it, your box deserves to be pwned. – Chris Wesseling – 2014-03-12T20:40:59.047

3

This reminds me of Magic Eyes. I might still be here guessing whether it was real or not if you hadn't pointed it out.

– Radiodef – 2014-03-13T01:20:08.753

5@roippi Haha, you dumb bastard. It's not a schooner, it's a SAILBOAT! – MikeTheLiar – 2014-03-13T14:52:48.517

1I don't see anything... – None – 2014-03-13T22:43:28.113

1I find I can see it better if I randomly scroll up and down smoothly, also the numbers are about a inch high - and 23 seems to show up better. – Mateo – 2014-03-14T04:30:35.470

7Protip: copy/paste to Notepad++ and zoom all the way out. – MikeTheLiar – 2014-03-14T18:59:38.893

54

Brainfuck

I'm so bad at ASCII art !

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

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

Michael M.

Posted 2014-03-12T04:58:13.953

Reputation: 12 173

This is a really nice solution :) – gilbertohasnofb – 2014-03-13T15:14:36.307

47

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

user15244

Posted 2014-03-12T04:58:13.953

Reputation:

10The obfuscation here is pretty supreme for being simple substitution. – Radiodef – 2014-03-13T01:14:53.023

1Doesn't it run into stack overflow due to recursion? – Ski – 2014-03-13T16:52:31.240

@Skirmantas I assume all compilers will use tail-recursion for this (eg. replace the call to main with a jump to main). – Tyilo – 2014-03-13T22:31:51.907

44

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

Sebastian Negraszus

Posted 2014-03-12T04:58:13.953

Reputation: 1 471

10+1 For someone that actually went to oeis.org in order to research a formula that fits the sequence :) – MrPaulch – 2014-03-17T06:57:16.563

a(i)=a(i-1)+a(i-3)+a(i-5) really seems like an easier solution – Cruncher – 2014-03-20T20:40:47.743

1@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 – 2014-03-20T21:01:05.727

29

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.

Rik

Posted 2014-03-12T04:58:13.953

Reputation: 781

@kódfodrász thanks for the suggested edit! – Rik – 2014-03-14T11:44:48.253

6I see a numeral 8 in there, you bad person you – Thebluefish – 2014-03-15T14:20:12.767

@Thebluefish I am ashamed. – Rik – 2014-03-17T08:11:19.547

25

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

Tony Ellis

Posted 2014-03-12T04:58:13.953

Reputation: 1 706

@cegprakash And before C was B – SirPython – 2015-04-09T00:33:43.650

6ASCII arithmetic is best arithmetic. – Pharap – 2014-03-15T17:42:33.627

2So after C, came a language called D? – cegprakash – 2014-03-20T09:01:38.957

24

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!

sh54

Posted 2014-03-12T04:58:13.953

Reputation: 341

2Plus one for ingenuity. Welcome to PPCG! – Jonathan Van Matre – 2014-03-13T23:27:24.117

22

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

r3mainer

Posted 2014-03-12T04:58:13.953

Reputation: 19 135

11As pretty as this may be, I count three 4s and two 8s in there. – Geobits – 2014-03-13T02:33:56.527

6@Geobits I obviously need a new pair of squinting goggles! Fixed now. – r3mainer – 2014-03-13T08:28:07.880

20

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.

repeat cf

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}}]

quad irr 1

where the 0 refers to the implicit integer part.

We can check by inverting the operation:

enter image description here

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

c

{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"]]

table

DavidC

Posted 2014-03-12T04:58:13.953

Reputation: 24 524

Well, that is one nice math solution. I really like this one – C5H8NNaO4 – 2014-03-17T17:59:19.060

@C5H8NNaO4, Thanks, MSG. It was fun to figure out. – DavidC – 2014-03-18T01:26:54.390

1+1 You edited to get rid of the 16 in the fraction while I was typing a comment about it. – Geobits – 2014-03-18T01:27:42.797

@Geobits. Funny about that. I thought I'd check whether I satisfied the rules; there were several violations that I since fixed. – DavidC – 2014-03-18T03:00:40.403

19

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.

John Dvorak

Posted 2014-03-12T04:58:13.953

Reputation: 9 048

2I love the way Haskell and the like do functional programming :D – Jwosty – 2014-03-12T12:14:08.857

2fromEnum looks nicer than Data.Char.ord, and is somewhat shorter – mniip – 2014-03-12T13:43:10.867

1Whuh ... how? Could you explain? – Pureferret – 2014-03-13T14:57:22.347

@Pureferret Haskell only replaces computations with their results if it absolutely needs the results. A list is either an empty list or an element and a list of successors. What exactly do you want explained? – John Dvorak – 2014-03-13T16:24:00.127

1I just noticed the innocuous characters right at the end. I assume the have something to do with it? – Pureferret – 2014-03-13T17:01:48.310

1Ah. Yes, indeed, they do. – John Dvorak – 2014-03-13T17:20:58.183

@MrLister better now? – John Dvorak – 2014-03-14T07:03:26.327

did you know you can rewrite (+)(-ord 'D') to (-ord 'D'+)? this is parsed as a section of + so that it adds -ord 'D' to the input – proud haskeller – 2014-09-27T13:17:00.350

19

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

sam hocevar

Posted 2014-03-12T04:58:13.953

Reputation: 581

18

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

Geobits

Posted 2014-03-12T04:58:13.953

Reputation: 19 061

1

Minus the while(true): http://ideone.com/1xaPdO

– Tim S. – 2014-03-12T20:30:48.327

7

There is a pattern, but it's not... very obvious: https://oeis.org/A130826 :)

– Sebastian Negraszus – 2014-03-12T20:51:26.620

14

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.

Heinzi

Posted 2014-03-12T04:58:13.953

Reputation: 241

You can also pipe awk -F"[ ,]" '/%S/ {for (i=3;i<=9;i++) printf $i" "}' to curl. – fedorqui – 2014-03-13T13:18:31.200

1You 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 – 2014-03-14T06:20:56.813

@DigitalTrauma: Thanks, I did not know about yes and curl -s -- I just shamelessly added this to my answer. :-) – Heinzi – 2014-03-14T06:33:57.187

13

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

asr

Posted 2014-03-12T04:58:13.953

Reputation: 361

12

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])

bodo

Posted 2014-03-12T04:58:13.953

Reputation: 221

very clever! Nice. – DavidC – 2014-03-25T12:26:04.867

11

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.

DocMax

Posted 2014-03-12T04:58:13.953

Reputation: 704

11

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.

grovesNL

Posted 2014-03-12T04:58:13.953

Reputation: 6 736

10

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}

daniero

Posted 2014-03-12T04:58:13.953

Reputation: 17 193

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 – 2014-03-21T15:35:38.147

10

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

orion

Posted 2014-03-12T04:58:13.953

Reputation: 3 095

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 – 2014-03-13T17:25:17.210

Or just cycle the string to "gAELMT" :) – orion – 2014-03-13T18:53:26.540

Sure, unless someone invokes your program with arguments :) Still printing garbage half the time, though. – jerry – 2014-03-14T00:56:25.730

3If you give arguments to a program that doesn't need any, you pay the price :) – orion – 2014-03-14T09:42:50.490

You can still save a lot of characters in this. For loop can be preferred over while loop. " " can be used instead of "\n". – cegprakash – 2014-03-20T11:56:24.820

1for 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 – 2014-03-20T14:36:44.603

9

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.

ion

Posted 2014-03-12T04:58:13.953

Reputation: 91

Welcome to the site =) – Riot – 2014-03-16T09:28:26.160

8

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.

Fastas

Posted 2014-03-12T04:58:13.953

Reputation: 197

6There are 4s and 8s inside. – zakk – 2014-03-14T11:31:56.617

7

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

Andrew Soutar

Posted 2014-03-12T04:58:13.953

Reputation: 71

1Easy to fix, but you still have a 4 in polynomial. – Geobits – 2014-03-13T02:28:15.367

@Geobits whoops, didn't notice that. Thanks. – Andrew Soutar – 2014-03-13T02:45:07.347

6

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.

Jordon Biondo

Posted 2014-03-12T04:58:13.953

Reputation: 1 030

6

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

CCP

Posted 2014-03-12T04:58:13.953

Reputation: 632

6

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

Riot

Posted 2014-03-12T04:58:13.953

Reputation: 4 639

6

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

agrif

Posted 2014-03-12T04:58:13.953

Reputation: 61

Welcome to the site =) – Riot – 2014-03-16T09:27:35.050

+1 for "it requires a scheme implementation with infinite-accuracy support for quadratic irrationals, which (AFAIK) doesn't exist." – Lyndon White – 2014-03-18T11:21:15.203

6

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

alexandercannon

Posted 2014-03-12T04:58:13.953

Reputation: 161

5

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

ninjalj

Posted 2014-03-12T04:58:13.953

Reputation: 3 018

4

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

rdurand

Posted 2014-03-12T04:58:13.953

Reputation: 149

Does this output the number infinitely? Also, you are typically supposed to provide the full program or function when solving challenges. – None – 2014-03-12T16:19:01.303

Yes, it does print infinitely beacause of the never-ending for loop. I updated the code with more context, I thought just the "interesting part" was enough :) – rdurand – 2014-03-12T16:30:49.427

4

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);

Alma Do

Posted 2014-03-12T04:58:13.953

Reputation: 161

3

Java

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

The Numbers

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

Radiodef

Posted 2014-03-12T04:58:13.953

Reputation: 2 414

Dat Swing... Why do you put code in an inner JFrame class? Why not extend JFrame or create an object and call methods on it? – nrubin29 – 2014-03-12T23:33:01.177

1@nrubin29 Just to amuse myself. – Radiodef – 2014-03-12T23:34:59.713

1Alright, fair enough. – nrubin29 – 2014-03-12T23:54:12.300

Would the animated gif itself not count as an entry? It's a program, too. – kojiro – 2014-03-13T13:20:06.750

3

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]);
}

Jussi M

Posted 2014-03-12T04:58:13.953

Reputation: 179

3

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

Brad

Posted 2014-03-12T04:58:13.953

Reputation: 141

3

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.

user1502040

Posted 2014-03-12T04:58:13.953

Reputation: 2 196

Perhaps you should post a spoiler - use >! at the beginning of the line to do so. – None – 2014-03-12T22:31:20.320

3

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

sebcap26

Posted 2014-03-12T04:58:13.953

Reputation: 1 301

3

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

Dmitry

Posted 2014-03-12T04:58:13.953

Reputation: 39

3

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) ")

xem

Posted 2014-03-12T04:58:13.953

Reputation: 5 523

3

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]);
}

Oberon

Posted 2014-03-12T04:58:13.953

Reputation: 2 881

3

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

X123M3-256

Posted 2014-03-12T04:58:13.953

Reputation: 31

3

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

zakk

Posted 2014-03-12T04:58:13.953

Reputation: 161

3

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?

CompuChip

Posted 2014-03-12T04:58:13.953

Reputation: 439

3

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))" "
    }
}

user19214

Posted 2014-03-12T04:58:13.953

Reputation:

3

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

Wlerin

Posted 2014-03-12T04:58:13.953

Reputation: 131

3

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.

Jay

Posted 2014-03-12T04:58:13.953

Reputation: 131

Nice job, but you accidentally included a 4 and a 1 followed by a 5. Is there anyway you can fix this? – None – 2014-03-18T23:11:52.947

@hosch250 Arggh, I rewrote a couple of the constants as products -- like I put 202 instead of 40 -- just to get around that. But obviously I missed a couple. But it's easy enough to eliminate them. Change 2400 to 12002, and 15332 to, umm, 612222. One could, of course, work in some of the techniques used by others to do it without using digits at all, "four".length() to get 4 for example. But it seemed inelegant to mix techniques. – Jay – 2014-03-19T14:11:49.540

You can edit your answer--how about fixing those problems? – ErikE – 2014-03-19T17:24:00.573

Well, okay. I generally avoid making those kinds of edits to keep the original comment comprehensible. But there, done. – Jay – 2014-03-19T20:44:14.443

3

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 [__
            _-
            (- (* __ __) (*))
            (* __ __)
            (- (* __ _') (*))
            (* _' (- _- (*)))]))))

Matthew Moss

Posted 2014-03-12T04:58:13.953

Reputation: 141

1Welcome to the PPCG Stack Exchange! Other users might find your answers more valuable if you provide information or brief explanations as to why your program is supposed to do what you say it does. – David Wilkins – 2014-03-19T13:47:16.537

1Okay… (*) is a multiply with no arguments; its result is 1. t is 2. f is 4. The rest should be pretty basic. – Matthew Moss – 2014-03-19T14:27:45.933

3

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

Puru--

Posted 2014-03-12T04:58:13.953

Reputation: 131

3

Perl

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

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

Fingashpitzzz

Posted 2014-03-12T04:58:13.953

Reputation: 31

2

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

user80551

Posted 2014-03-12T04:58:13.953

Reputation: 2 520

2

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.

gilbertohasnofb

Posted 2014-03-12T04:58:13.953

Reputation: 494

Why the negative vote? Did I miss something here? – gilbertohasnofb – 2014-03-12T17:00:01.423

Probably because there has been another answer with the same idea, or it is because the idea is boring. – n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ – 2014-03-22T16:38:50.267

2

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));

Oriol

Posted 2014-03-12T04:58:13.953

Reputation: 792

2

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.

CompuChip

Posted 2014-03-12T04:58:13.953

Reputation: 439

2

C

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

Stephen Melvin

Posted 2014-03-12T04:58:13.953

Reputation: 183

2

Brainf**k

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

Timtech

Posted 2014-03-12T04:58:13.953

Reputation: 12 038

2

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

Dave Forber

Posted 2014-03-12T04:58:13.953

Reputation: 207

Welcome to the site! – Jonathan Van Matre – 2014-03-12T23:38:24.603

2

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

TheOneWhoPrograms

Posted 2014-03-12T04:58:13.953

Reputation: 129

You have a lot of 4's in there – durron597 – 2014-03-14T13:32:00.213

Bah, I missed the fact that the number 4 couldn't be used anywhere in a number. I shall make the appropriate edits ;) – TheOneWhoPrograms – 2014-03-14T13:39:36.277

I would find this funnier in a personal way if they were named like NOT_FOUR, NOT_EIGHT, etc. You know, just to be sure what they "aren't". ; P – Radiodef – 2014-03-18T06:54:53.450

haha, that would be pretty good :p I'll keep that in mind for next one I do to do something funny with variables. – TheOneWhoPrograms – 2014-03-18T07:19:55.780

2

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

luxcem

Posted 2014-03-12T04:58:13.953

Reputation: 151

2

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.

Teun Pronk

Posted 2014-03-12T04:58:13.953

Reputation: 2 599

primes[8] probably needs to be changed as You may not use the numeral 8.. Maybe I am too strict in interpreting this. – TheConstructor – 2014-03-13T22:35:15.403

Ooops I didnt see that one lol.. let me fix that.. – Teun Pronk – 2014-03-14T08:51:40.047

Changed it to (primes[1]*primes[3])+primes[0] which is (3*7)+2 :) Thanks for noting that – Teun Pronk – 2014-03-14T08:54:31.323

2

Java

THE NUMBERS

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

durron597

Posted 2014-03-12T04:58:13.953

Reputation: 4 692

2

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

Hinek

Posted 2014-03-12T04:58:13.953

Reputation: 121

2

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.

TheConstructor

Posted 2014-03-12T04:58:13.953

Reputation: 563

2

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

V-SHY

Posted 2014-03-12T04:58:13.953

Reputation: 121

2

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

Ruben

Posted 2014-03-12T04:58:13.953

Reputation: 129

2

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.

alexander-brett

Posted 2014-03-12T04:58:13.953

Reputation: 1 485

2

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

michal.hubczyk

Posted 2014-03-12T04:58:13.953

Reputation: 121

2

Just:

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

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

Lodewijk

Posted 2014-03-12T04:58:13.953

Reputation: 121

2

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

ajax16384

Posted 2014-03-12T04:58:13.953

Reputation: 21

2

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

histocrat

Posted 2014-03-12T04:58:13.953

Reputation: 20 600

2

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

?>

BlueCacti

Posted 2014-03-12T04:58:13.953

Reputation: 129

Thx for the downvotes ... – BlueCacti – 2014-03-24T13:05:09.160

2

Python

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

-0.225x5 + 4.25x4 - 29.375x3 + 91.75x2 - 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.

hacatu

Posted 2014-03-12T04:58:13.953

Reputation: 229

2

C

Not very creative, I'm afraid.

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

Florian F

Posted 2014-03-12T04:58:13.953

Reputation: 591

2

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.

irufushi

Posted 2014-03-12T04:58:13.953

Reputation: 29

2

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

enter image description here

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. Took me a while to figure this out though

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

enter image description here

C5H8NNaO4

Posted 2014-03-12T04:58:13.953

Reputation: 1 340

2

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

Anant

Posted 2014-03-12T04:58:13.953

Reputation: 21

2

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

Easton

Posted 2014-03-12T04:58:13.953

Reputation: 21

2

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)

ErikE

Posted 2014-03-12T04:58:13.953

Reputation: 123

2

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

Andy Burton

Posted 2014-03-12T04:58:13.953

Reputation: 121

2

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')]
>>> 

Paddy3118

Posted 2014-03-12T04:58:13.953

Reputation: 121

2

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

damix911

Posted 2014-03-12T04:58:13.953

Reputation: 121

1

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()

Ol' Reliable

Posted 2014-03-12T04:58:13.953

Reputation: 129

Thanks for the edit, I didn't think that could also work! – Ol' Reliable – 2014-03-12T17:47:08.337

1

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]);
        }
    }
}

jerry

Posted 2014-03-12T04:58:13.953

Reputation: 489

1

C++

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

Mukul Kumar

Posted 2014-03-12T04:58:13.953

Reputation: 2 585

Could down-voter explain why he/she don't like the answer ? – Mukul Kumar – 2014-03-13T03:24:45.497

1Could be because this is basically the same as the "valid, but uninspired" version in the OP. – Geobits – 2014-03-13T12:56:38.017

1

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.

Martin Thoma

Posted 2014-03-12T04:58:13.953

Reputation: 669

Of course to use your PI method, you would have to first calculate PI to 176,025,497 digits. And then you couldn't index into the digits using pi.substring(176025488) because that includes the digits 4 and 8. :-) – Jay – 2014-03-18T22:17:37.937

@Jay To get 176025488 you can use π again. You could split it up to 176025 and 488. You can use 176025 directly and use the 321-323 position to get 488. – Martin Thoma – 2014-03-18T22:26:37.737

1

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]);}

Pruthvi Raj

Posted 2014-03-12T04:58:13.953

Reputation: 141

1

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.

ɐɔıʇǝɥʇuʎs

Posted 2014-03-12T04:58:13.953

Reputation: 4 449

1

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])

Jussi M

Posted 2014-03-12T04:58:13.953

Reputation: 179

1

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

ahy1

Posted 2014-03-12T04:58:13.953

Reputation: 191

1

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

zxc

Posted 2014-03-12T04:58:13.953

Reputation: 11

2It works, but it's essentially the same concept as the questioner's given example, "a valid (but not very inspired) Java program". p.s. Minor style point: custom is to use the Markdown header syntax ## JavaScript at the top of your answer instead of just bolding the text...unless you are deliberately trolling the folks with OCD. :) Welcome to the site! – Jonathan Van Matre – 2014-03-15T12:37:05.450

1

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

TecBrat

Posted 2014-03-12T04:58:13.953

Reputation: 222

1

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

PyRulez

Posted 2014-03-12T04:58:13.953

Reputation: 6 547

1

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

max.haredoom

Posted 2014-03-12T04:58:13.953

Reputation: 369

1

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

wuiyang

Posted 2014-03-12T04:58:13.953

Reputation: 371

1

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])

aperson

Posted 2014-03-12T04:58:13.953

Reputation: 111

1

Haskell, phoning it in.

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

mmachenry

Posted 2014-03-12T04:58:13.953

Reputation: 191

And the number 15. Both issues easily fixed if you used +3 instead of +1. – Jonathan Van Matre – 2014-03-18T15:12:02.913

Hehe, clearly not paying attention. – mmachenry – 2014-03-18T15:17:00.150

1

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

Danek

Posted 2014-03-12T04:58:13.953

Reputation: 361

1

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

BenVlodgi

Posted 2014-03-12T04:58:13.953

Reputation: 361

1

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

Leandro Poblet

Posted 2014-03-12T04:58:13.953

Reputation: 111

1

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.

Bill Woodger

Posted 2014-03-12T04:58:13.953

Reputation: 1 391

1

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

Orion

Posted 2014-03-12T04:58:13.953

Reputation: 21

1

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.

GregRos

Posted 2014-03-12T04:58:13.953

Reputation: 113

1

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.

n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

Posted 2014-03-12T04:58:13.953

Reputation: 5 683

1

Python3

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

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

Aleksi Torhamo

Posted 2014-03-12T04:58:13.953

Reputation: 1 871

1

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.

1j01

Posted 2014-03-12T04:58:13.953

Reputation: 131

1

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.

overactor

Posted 2014-03-12T04:58:13.953

Reputation: 3 500

1

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

Gust van de Wal

Posted 2014-03-12T04:58:13.953

Reputation: 630

0

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

Alex

Posted 2014-03-12T04:58:13.953

Reputation: 47

0

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

Henry F

Posted 2014-03-12T04:58:13.953

Reputation: 109

0

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

Vishwanath gowda k

Posted 2014-03-12T04:58:13.953

Reputation: 119