Multiples of the number 2

Codes to write a program that keeps printing the multiples of the number 2. The loop should not terminate.
FOR i = 2 TO 65534 STEP 2
PRINT i
NEXT
But... that loop eventually terminates...

i = 2
FOR j = 1 TO 5 STEP 1
    PRINT i
    i = i + 2
    j = j - 1
NEXT j

Last edited on

cout << "2 " << "4 " << "6 " << "8 " << ... etc etc. will never terminate, but typing it in might take a while.
Last edited on
int x=2, y=1;
do
{
cout<<x<<endl;
x+=2;
}
while(y==1);
@ jsmith: did you write that in BASIC?
closed account (z05DSL3A)
1
2
3
4
5
6
7
8
#include <iostream>

int main()
{
    while(true) 
        std::cout << "the multiples of the number 2. ";
    return 0;
}
Yeah, been a long time :)

I never wrote an obfuscated BASIC program, but I just thought of this:


i = 2
FOR j = 1 TO 2 STEP 1
    PRINT i
    i = i + 2
    j = j AND NOT 1
NEXT j


Wait... or is it that I never wrote a non-obfuscated program in BASIC?
Non-terminating arithmetic sequence f(n) = f(n-1)+2 in Tcl
for {set n 0} true {} {puts [incr n 2]}

:-]
@jsmith: that program is easy to read, so its non-obfuscated
Thanks everyone for your contribution
Topic archived. No new replies allowed.