We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Numeric machine

From Esolang
Jump to navigation Jump to search

Numeric machine is a program form designed by PSTF.

Overview

A numeric machine should do like this:

  1. Receive user input.
  2. If the user enters 0, output 0 infinitely.
  3. Otherwise, let the number entered by the user be n, and output this number n times.
  4. If the user enters a negative number, take its absolute value.
  5. If the user enters a decimal, truncate the decimal part, and then process it according to the rules for integers.

Challenge Area

Python

a = int(input())
if a == 0:
    while True:
        print(0)
else:
    a = floor(abs(a)) # The absolute value of a positive number is itself
    for i in range(a):
        print(a)

The Second Coming

open a = Int(input())
if a == 0:
    while True:
        print(0)
    endwhile
else:
    a = floor(abs(a)) # The absolute value of a positive number is itself
    for i in interval(a):
        print(a)
    endfor
endif

<><

Note: <>< don't have numeric input, so the program will input a character and output it x times where x is character code. 0 outputs NUL infinitely

i:&:?v>0o<
&;!?:<-1&o:

node.js

uses prompt for input

y=x=+prompt()
y=z=Math.abs(Math.trunc(x))
while(y--||!z)console.log(x)

Septem Lingua

let i <- float(stdin)
@import abs,floor from math
let j <- floor(abs(i))
if j==0 then
    while j==0 do
        print i
    end
else
    for i from 1 to j do
        print i
    end
end

C/C++

#include <stdio.h>
#include <stdlib.h>  // for atoi, abs

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);
    if (n == 0) {
        while (1) {
            printf("0\n");
        }
    } else {
        int count = abs(n);
        for (int i = 0; i < count; i++) {
            printf("%d\n", n);
        }
    }
    return 0;
}

See Also

Categories