136k views
22 votes
Write a sub program to find the factors of a supplied number


User Thucnguyen
by
4.9k points

1 Answer

3 votes

Answer:

There are two options I can think of for you,

(Qbasic Code)

To Find the Factors of Given Number:

CLS

INPUT "Enter any number"; n

FOR i = 1 TO n

x = n MOD i

IF x = 0 THEN

PRINT i;

END IF

NEXT i

END

To Find the Factors of Given Number Using COMMON SHARED:

DECLARE SUB factor ()

COMMON SHARED n

CLS

CALL factor

END

SUB factor

INPUT "Enter any number"; n

FOR i = 1 TO n

x = n MOD i

IF x = 0 THEN

PRINT i;

END IF

NEXT i

END SUB

User Yohan Danvin
by
5.7k points