How to resolve the algorithm Largest proper divisor of n step by step in the Ada 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 Ada 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 Ada programming language

Source code in the ada programming language

with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   subtype param_type is Integer range 1 .. 100;
   function lpd (n : in param_type) return param_type is
      result : param_type := 1;
   begin
      for divisor in reverse 1 .. n / 2 loop
         if n rem divisor = 0 then
            result := divisor;
            exit;
         end if;
      end loop;
      return result;
   end lpd;

begin
   for I in param_type loop
      Put (Item => lpd (I), Width => 3);
      if I rem 10 = 0 then
         New_Line;
      end if;
   end loop;
end Main;


  

You may also check:How to resolve the algorithm Hello world/Newbie step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Sorting algorithms/Permutation sort step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Truth table step by step in the Clojure programming language
You may also check:How to resolve the algorithm Percentage difference between images step by step in the Lua programming language
You may also check:How to resolve the algorithm Old lady swallowed a fly step by step in the AutoHotkey programming language