RosettaCodeData/Task/Semiprime/QuickBASIC/semiprime.basic
2026-04-30 12:34:36 -04:00

24 lines
437 B
Text

' Semiprime
DECLARE FUNCTION Count% (BYVAL N%)
INPUT "Enter an integer: ", N%
IF Count%(N%) = 2 THEN
PRINT "It is a semiprime."
ELSE
PRINT "It is not a semiprime."
END IF
END
FUNCTION Count% (BYVAL N%)
N% = ABS(N%)
Result% = 0
IF N% >= 2 THEN
FOR Factor% = 2 TO N%
WHILE N% MOD Factor% = 0
Result% = Result% + 1
N% = N% \ Factor%
WEND
NEXT Factor%
END IF
Count% = Result%
END FUNCTION