Prime Composite Testing Program

CLS
INPUT "Test Number: ";N
'f is flag which is set to 0 indicating testing number is prime and 1 indicating testing number is composite
F=0
FOR I=2 TO N/2
     IF N MOD I=0 THEN
         F=1
         EXIT FOR
     ENDIF
NEXT I
IF F=0 THEN
   PRINT N;" IS PRIME NUMBER"
ELSE
   PRINT N;" IS COMPOSITE NUMBER"
ENDIF

8 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. DECLARE FUNCTION a (n)
    CLS
    g = a(n)
    END

    FUNCTION a (n)
    INPUT "enter a no:", n
    FOR i = 1 TO n
    b = n MOD i
    IF b = 0 THEN f = f + 1
    NEXT i
    IF f > 2 THEN
    PRINT "composite "
    ELSE
    PRINT "Prime"
    END IF
    END FUNCTION

    ReplyDelete
  3. Replies
    1. f is local variable used for storing value or remainder of b...

      Delete
  4. wap to get a name from user and print out the initial characters of each word

    ReplyDelete
  5. how to find reverse of string word

    ReplyDelete
    Replies
    1. Cls
      Input A$
      L=len (A$)
      For I=L to 1 step -1.(no dot)
      b$=b$+mid$(a$,i,1)
      Next I
      Print b$
      End


      Delete