QBASIC SERIES : 3,10,5,16,8,4,2,1...............UPTO 10TH TERM

QBASIC SERIES : 3,10,5,16,8,4,2,1...............UPTO 10TH TERM



CLS
 A = 3
 FOR I = 1 TO 11
 PRINT A;
 IF A MOD 2 = 0 THEN
 A = A \ 2
 ELSE
 A = A * 3 + 1
 END IF
 NEXT I
 END

USING SUB


DECLARE SUB SER()
 CLS
 CALL SER
 END
 
 SUB SER
 A = 3
 FOR I = 1 TO 11
 PRINT A;
 IF A MOD 2 = 0 THEN
 A = A / 2
 ELSE
 A = A * 3 + 1
 END IF
 NEXT I
 END SUB

Post a Comment

0 Comments