Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ Challenge 9001

Name: Anonymous 2011-05-01 19:51

The correct title of this article is /prog/ Challenge 9001. It appears incorrectly here because of technical restrictions.

The task:

Print numbers from 1 to 1000 without using any loop or conditional statements. Don't just write the printf() or cout statement 1000 times.

inb4 lipthfags and dead dogs using some obscure functionality of their obscure languages.

Name: Anonymous 2011-05-02 4:12

(1..1000)>>.say

That's autoparallel, not looped. (There was no mention of ordering.)

No loops and no tests and in C no less:

#include <signal.h>
static void handler(int signum) { exit(0); }

float output(int x) {
  float a=1/x--;
  printf("%d\n", 1000 - x);
  output(x);
 
  return a; // not tail recursive
}

int main(void) {
  struct na;
  na.sa_handler = handler;
  sigemptyset(&na.sa_mask);
  sigaction(SIGFPE, &na, NULL);
  output(1000);
 
  return 0;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List