How to resolve the algorithm FizzBuzz step by step in the NATURAL programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm FizzBuzz step by step in the NATURAL programming language

Table of Contents

Problem Statement

Write a program that prints the integers from   1   to   100   (inclusive).

But:

The   FizzBuzz   problem was presented as the lowest level of comprehension required to illustrate adequacy.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm FizzBuzz step by step in the NATURAL programming language

Source code in the natural programming language

DEFINE DATA                               
LOCAL                                     
1 #I       (I4)                           
1 #MODULO  (I4)                           
1 #DIVISOR (I4)                           
1 #OUT     (A10)                          
END-DEFINE                                
*                                         
FOR #I := 1 TO 100                        
  #DIVISOR := 15                          
  #OUT := 'FizzBuzz'                      
  PERFORM MODULO                          
*                                         
  #DIVISOR := 5                           
  #OUT := 'Buzz'                          
  PERFORM MODULO                          
*                                         
  #DIVISOR := 3                           
  #OUT := 'Fizz'                          
  PERFORM MODULO                          
*                                         
  WRITE #I                                
END-FOR                                   
*                                         
DEFINE SUBROUTINE MODULO                  
#MODULO := #I - (#I / #DIVISOR) * #DIVISOR
IF #MODULO = 0                            
  WRITE NOTITLE #OUT                      
  ESCAPE TOP                              
END-IF                                    
END-SUBROUTINE                            
*                                         
END

  

You may also check:How to resolve the algorithm Hello world/Text step by step in the Mythryl programming language
You may also check:How to resolve the algorithm Fast Fourier transform step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Search a list step by step in the Ada programming language
You may also check:How to resolve the algorithm Superpermutation minimisation step by step in the Racket programming language
You may also check:How to resolve the algorithm Hello world/Graphical step by step in the Scilab programming language