10 PRINT CHR$(205.5+RND(1));: GOTO 10

Use this forum to submit new files for the download section of the archive. I will check each submission and upload it to the archive on a regular basis.
Post Reply
User avatar
jgerrie
Posts: 146
Joined: Thu Jun 28, 2012 3:01 pm
Location: Cape Breton, Nova Scotia, Canada
Contact:

10 PRINT CHR$(205.5+RND(1));: GOTO 10

Post by jgerrie »

10 PRINT CHR$(205.5+RND(1)); : GOTO 10
A famous Commodore 64 one-liner. Academic books have been written inspired by this wee program. Now we have a Dragon/Coco/MC-10 version of this programming "great"! Take that Commodore 64!
Attachments
GREAT.CAS
(682 Bytes) Downloaded 247 times
User avatar
tormod
Posts: 416
Joined: Sat Apr 27, 2013 12:06 pm
Location: Switzerland
Contact:

Re: 10 PRINT CHR$(205.5+RND(1));: GOTO 10

Post by tormod »

jgerrie wrote:10 PRINT CHR$(205.5+RND(1)); : GOTO 10
I think it should be RND(0) since RND(1) always returns 1. Anyway, the one-liner in the CAS file is much more impressive :)
User avatar
jgerrie
Posts: 146
Joined: Thu Jun 28, 2012 3:01 pm
Location: Cape Breton, Nova Scotia, Canada
Contact:

Re: 10 PRINT CHR$(205.5+RND(1));: GOTO 10

Post by jgerrie »

That snippet of code is from the Commodore 64. I'm not sure, but I think in that variation of Basic, 1 returns a decimal. It's a famous one-liner for that machine, which my program now impliments in Color Basic. Unlike Color Basic, I don't think Commodore Basic's RND function can return whole numbers as an option. You can only use 1 and it always returns a random fraction between 0 and 1. This was common in some variations of Microsoft Basic, hence the ubiquitous N=INT(RND(1)*10)+1 to just get a number between 1 and 10. Color Basic's N=RND(10) is so much more straight forward...
Post Reply