WAP to find/print prime factorial of a number

Qbasic program to find/print prime factorial of a number



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

USING SUB


DECLARE SUB PRIMEFACTORIAL(N)
 CLS
 INPUT "ENTER ANY NUMBER"; N
 CALL PRIMEFACTORIAL(N)
 END
 
 SUB PRIMEFACTORIAL(N)
 F = 1
 FOR I = 1 TO N
 C = 0
 FOR J = 1 TO I
 IF I MOD J = 0 THEN C = C + 1
 NEXT J
 IF C = 2 THEN F = F * I
 NEXT I
 PRINT "PRIME FACTORIAL ="; F
 END SUB

Post a Comment

0 Comments