QBASIC PROGRAM TO FIND PRIME FACTORS OF A NUMBER

QBASIC PROGRAM TO FIND PRIME FACTORS OF A NUMBER



CLS
 INPUT ENTER ANY NUMBER; N
 PRINT "PRIME FACTORS OF"; N; =;
 FOR I = 1 TO N
 C = 0
 FOR J = 1 TO I
 IF I MOD J = 0 THEN C = C + 1
 NEXT J
 IF N MOD I = 0 AND C = 2 THEN PRINT I;
 NEXT I
 END

USING SUB


DECLARE SUB FACTOR(N)
 CLS
 INPUT ENTER ANY NUMBER; N
 CALL FACTOR(N)
 END
 
 SUB FCATOR(N)
 PRINT "PRIME FACTORS OF"; N; =;
 FOR I = 1 TO N
 C = 0
 FOR J = 1 TO I
 IF I MOD J = 0 THEN C = C + 1
 NEXT J
 IF N MOD I = 0 AND C = 2 THEN PRINT I;
 NEXT I
 END SUB

Post a Comment

0 Comments