FACTOR, FACTORIAL , PRIME FACTOR AND PRIME FACTORIAL QBASIC PROGRAMS



131. WAP to input any number and display the factors.
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (N)
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END SUB






132. WAP to input any number and display the prime factors.

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 PROCEDURE

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (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

133. WAP to input any number and find sum of factors.
CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
PRINT "SUM OF FACTORS="; S
END
USING SUB PROCEDURE

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (N)
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
PRINT "SUM OF FACTORS="; S
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "SUM OF FACTORS=";  FACT (N)
END

FUNCTION FACT (N)
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
FACT = S
END FUNCTION

134. WAP to input any number and display the factorial of a given number.
CLS
INPUT "ENTER ANY NUMBER"; N
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
PRINT "FACTORIAL ="; F
END

USING SUB PROCEDURE

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (N)
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
PRINT "FACTORIAL ="; F
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "FACTORIAL ="; FACT (N)
END

FUNCTION FACT (N)
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
FACT = F
END FUNCTION

135. WAP to input any number and display the prime factorial of a given 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 PROCEDURE

DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END

SUB FACT (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
USING FUNCTION PROCEDURE

DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "PRIME FACTORIAL ="; FACT (N)
END

FUNCTION FACT (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
FACT = F
END FUNCTION

Comments

Brijesh singh said…
This link help me a lot
Brijesh singh said…
Thanks a lot for making this link
Unknown said…
Thanks a lot u helped me a lot keep posting
Blogger said…
Do you understand there is a 12 word sentence you can communicate to your partner... that will trigger deep emotions of love and impulsive attraction for you buried within his chest?

Because hidden in these 12 words is a "secret signal" that fuels a man's instinct to love, admire and look after you with his entire heart...

12 Words Will Trigger A Man's Love Instinct

This instinct is so hardwired into a man's brain that it will drive him to try better than before to build your relationship stronger.

Matter-of-fact, triggering this powerful instinct is so important to achieving the best ever relationship with your man that once you send your man one of the "Secret Signals"...

...You will instantly find him expose his soul and heart to you in such a way he haven't experienced before and he will see you as the one and only woman in the world who has ever truly understood him.

Popular posts from this blog

PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER

PROGRAM TO DISPLAY SUM, PRODUCT, DIFFERENCE AND PRODUCT OF TWO / THREE NUMBERS

PALINDROME AND ARMSTRONG PROGRAMS