FizzBuzz in Larzscript
The classic interview warm-up: print 1 to N, but Fizz for multiples of 3, Buzz for multiples of 5, FizzBuzz for both.
No package needed - just the core language's while loop, modulo, and string concatenation.
Code
let i = 1
while i <= 15 {
if i % 15 == 0 { print("FizzBuzz") }
else if i % 3 == 0 { print("Fizz") }
else if i % 5 == 0 { print("Buzz") }
else { print(i) }
i = i + 1
}Output
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz
Why this matters in Larzscript
Nothing money-native here on purpose - this one's a baseline showing the core syntax reads like any modern scripting language before any of the wallet/pay primitives enter the picture.
Related
Reverse a String in LarzscriptFlip a string end to end - one of the smallest real string algorithms, and a good first look at the str package.→Check if a String is a Palindrome in LarzscriptDetect whether a string reads the same forwards and backwards, ignoring case, spaces and punctuation.→Sort a List in LarzscriptSort a list of numbers - and see exactly how many comparisons and swaps each algorithm actually costs.→Binary Search in LarzscriptFind a value in a sorted list in O(log n) instead of scanning every element.→