# BASIC malfunction

``` BBS: MOONFLOWER
Date: 02-29-92 (12:20)             Number: 99
From: SIDE OUT #7 @9150            Refer#: NONE
To:                               Recvd: YES
Subj: BASIC malfunction              Conf: (19) The Progra

MH#@>Re: BASIC malfunction
MH#@>By: Side Out #7 @9150 VirtualNET

MH#@>that you think that basic says 121/11-int(121/11)=.5
MH#@>while in fact your program is calculating 121/2-int(121/2) which really is
MH#@>0.5!

OK, I failed to say that there was a line to increment I#. Here's
the whole program. On either BASIC 3.31 for IBM or on the C-64, this
same program (with minor differences on the C-64 due to lack of an ELSE
statement, etc.), this program will say that both 49 and 121 (among
others) are prime numbers when they're divisible by 7 and 11 respect-
ively.
As I said before, it appears that this problem only happens when
the number entered is an odd square that has no other factors its
square root.

10 CLS
20 PRINT "Number Factory":PRINT
30 PRINT "Number to factor (12 digits max.)"
40 INPUT N#:IF N#<2 OR N#>=1E+13 THEN END
50 I#=2:NS#=SQR(N#):NU#=N#:CLS:PRINT N#,NS#:PRINT
60 XP=0
70 IF N#/I#=INT(N#/I#) THEN XP=XP+1:N#=N#/I#:GOTO 70
80 IF XP>0 THEN PRINT I#;:IF XP>1 THEN PRINT "^";XP ELSE PRINT
90 IF I#>2 THEN I#=I#+2 ELSE I#=I#+1
100 IF I#<NS# AND N#>1 THEN 60
110 IF N#>1 THEN PRINT N#;:IF N#=NU# THEN PRINT "is a prime number."
ELSE PRINT
120 PRINT:GOTO 30

* SLMR 2.1a * Logic is a wreath of pretty flowers which smell BAD!
```

Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET