Monday, October 11, 2021

Program to print the Numeric Series 3, 10, 5, 16, 8 (Hill-stone Number)

Using FOR...NEXT

CLS
n = 3
FOR i = 1 TO 5
     PRINT n;
     IF n MOD 2 = 0 THEN
          n = n / 2
     ELSE
          n = n * 3 + 1
     END IF
NEXT i
END


Using WHILE...WEND

CLS
n = 3
i = 1
WHILE i <= 5
     PRINT n;
     IF n MOD 2 = 0 THEN
          n = n / 2
     ELSE
          n = n * 3 + 1
     END IF
     i = i + 1
WEND
END


Using DO...LOOP

CLS
n = 3
i = 1
DO WHILE i <= 5
     PRINT n;
     IF n MOD 2 = 0 THEN
          n = n / 2
     ELSE
          n = n * 3 + 1
     END IF
     i = i + 1
LOOP
END

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...