The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Prime Number Search
07-19-2024, 01:40 PM (This post was last modified: 07-19-2024 10:12 PM by SlideRule.)
Post: #1
Prime Number Search
A excerpt from Interface Age, 1982-03, pg.12

… Instead of finding the PRIME numbers, it is quicker to search for the numbers that are NOT PRIME. The program to do this is listed here. …
      10 PRINT "Starting."
      20 DEFINT A-Z
      30 DIM A(1000)
      40 FOR I=2 TO 500
      50 FOR J=2 TO 32
      60 IF I*J>1000 GOTO 90
      70 A(I*J)=1
      80 NEXT J
      90 NEXT I
     100 FOR I=1 TO 1000
     110 IF A(I)=0 THEN PRINT I;
     120 NEXT I
     130 PRINT "Finished."
  Although the problem is trivial, the exercise emphasizes the importance of the approach adopted - a fairly simple revision of basic ideas …

BEST!
SlideRule

error corrected
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Prime Number Search - SlideRule - 07-19-2024 01:40 PM
RE: Prime Number Search - Allen - 07-19-2024, 08:36 PM
RE: Prime Number Search - SlideRule - 07-19-2024, 10:12 PM
RE: Prime Number Search - ttw - 07-19-2024, 11:57 PM
RE: Prime Number Search - John Keith - 07-20-2024, 12:31 PM
RE: Prime Number Search - ttw - 07-21-2024, 02:52 AM



User(s) browsing this thread: 1 Guest(s)