Integer sequence: Difference between revisions
Content added Content deleted
(+Haskell) |
(→{{header|BASIC}}: 5? Should have been 0.) |
||
Line 2: | Line 2: | ||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
<lang basic>5 LET A = |
<lang basic>5 LET A = 0 |
||
10 LET A = A + 1 |
10 LET A = A + 1 |
||
20 PRINT A |
20 PRINT A |
Revision as of 00:36, 13 February 2011
Integer sequence is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Create a program that, when run, would display all integers from 1 to ∞ (or any relevant implementation limit) if given enough time.
BASIC
<lang basic>5 LET A = 0 10 LET A = A + 1 20 PRINT A 30 GOTO 10</lang>
C
<lang c>#include <stdio>
int main() {
uint_32 i = 0; while(1) { printf("%u\n", ++i); }
return 0;
}</lang>
C++
<lang cpp>#include <iostream>
int main() {
uint_32 i = 0; while(true) { std::cout << ++i << std::endl; }
return 0;
}</lang>
Perl
<lang perl>my $i = 0; while(1) {
print ++$i . "\n";
} </lang>
Haskell
<lang haskell>mapM_ print [1..]</lang>