ScripticXLearn programming visually
Platform
Problems
Community
Leaderboard
Learn
Docs
MiniScript+ basicsVariablesOperators and expressionsInput and outputConditions and decisionsLoopsStringsSums, counts, and extremaDigits of a numberDivisibility and prime numbersNumeric sequences and recurrencesNumber basesFunctions and parametersRecursion
Examples
Basic programsConditionsInput and outputLoopsAlgorithmsWorking with textDigit problemsBase conversionsFunctions and recursionEncode text with a key
What's newHelpContact
Loading…

Examples

MiniScript+

ExamplesMiniScript+
Fundamentals
Basic programsConditionsInput and output
Programming patterns
LoopsAlgorithmsWorking with textDigit problemsBase conversionsFunctions and recursionEncode text with a key
Examples/Algorithms

Algorithms

Classic MiniScript+ algorithms with traceable state and compact implementations.

On this page
Prime number testFibonacci sequenceGreatest common divisorMaximum of three valuesWhy it works and what to test

These examples combine variables, conditions, and loops into complete algorithms.

Prime number test#

MS+prime.mspMiniScript+
1n = 72divisor = 23isPrime = n >= 24​5WHILE divisor * divisor <= n AND isPrime6  IF n MOD divisor == 0 THEN7    isPrime = FALSE8  END9  divisor = divisor + 110END11​12IF isPrime THEN13  PRINT "Prime"14ELSE15  PRINT "Not prime"16END

Expected result: Prime.

Fibonacci sequence#

MS+fibonacci.mspMiniScript+
1count = 52first = 03second = 14​5FOR index FROM 1 TO count6  PRINT first7  next = first + second8  first = second9  second = next10END

Expected result: 0, 1, 1, 2, 3.

Greatest common divisor#

Euclid's remainder method preserves the GCD and also handles a zero second argument. Inputs are non-negative integers, not both zero.

MS+gcd.mspMiniScript+
1first = 122second = 83​4WHILE second != 05  remainder = first MOD second6  first = second7  second = remainder8END9​10PRINT first

Expected result: 4.

Maximum of three values#

MS+maximum-three.mspMiniScript+
1first = 32second = 73third = 54maximum = first5​6IF second > maximum THEN7  maximum = second8END9​10IF third > maximum THEN11  maximum = third12END13​14PRINT maximum

Expected result: 7.

Why it works and what to test#

Primality excludes 0 and 1, then tries divisors through the square root, inclusively. Test 1, 2, 4, 49, 97. Fibonacci retains just two terms; the temporary value saves their sum before either is overwritten. GCD visits (12, 8), (8, 4), (4, 0); (12, 0) immediately prints 12. Maximum starts with an input value so negative inputs work too.

Read divisibility and numeric sequences. Use small inputs within the executor’s step and precision limits.

PreviousLoopsNextWorking with text

On this page

Prime number testFibonacci sequenceGreatest common divisorMaximum of three valuesWhy it works and what to test