How to resolve the algorithm Largest proper divisor of n step by step in the Modula-2 programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Largest proper divisor of n step by step in the Modula-2 programming language
Table of Contents
Problem Statement
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Largest proper divisor of n step by step in the Modula-2 programming language
Source code in the modula-2 programming language
MODULE LargestProperDivisor;
FROM InOut IMPORT WriteCard, WriteLn;
VAR i: CARDINAL;
PROCEDURE lpd(n: CARDINAL): CARDINAL;
VAR i: CARDINAL;
BEGIN
IF n=1 THEN
RETURN 1;
END;
FOR i := n DIV 2 TO 1 BY -1 DO
IF n MOD i = 0 THEN
RETURN i;
END;
END;
END lpd;
BEGIN
FOR i := 1 TO 100 DO
WriteCard(lpd(i), 3);
IF i MOD 10 = 0 THEN
WriteLn();
END;
END;
END LargestProperDivisor.
You may also check:How to resolve the algorithm Multiple distinct objects step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm Compile-time calculation step by step in the Perl programming language
You may also check:How to resolve the algorithm Vector step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Keyboard input/Flush the keyboard buffer step by step in the Nim programming language
You may also check:How to resolve the algorithm Subtractive generator step by step in the D programming language