1. `with Ada.Text_IO;           use Ada.Text_IO; `
2. `with HTMLTo API docTo specTo body; `
3. `with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; `
4. `package body MathematicsTo API docTo spec is `
5. ` `
6. `   function FactorialTo API docTo spec (ValueTo API docTo spec : Integer) return Integer is `
7. `      Return_Value : Integer := 1; `
8. `      Factor       : Integer := ValueTo API docTo spec; `
9. `   begin `
10. `      if ValueTo API docTo spec = 1 or ValueTo API docTo spec = 0 then `
11. `         return 1; `
12. `      else `
13. `         loop `
14. `            Return_Value := Return_Value * Factor; `
15. `            Factor       := Factor - 1; `
16. `            exit when Factor = 0; `
17. `         end loop; `
18. `         return Return_Value; `
19. `      end if; `
20. `   end FactorialTo API docTo specTo body; `
21. ` `
22. `   function N_over_KTo API docTo spec (nTo API docTo spec : Integer; kTo API docTo spec : Integer) return Integer is `
23. `      top : Integer := 1; `
24. `   begin `
25. `      if kTo API docTo spec > nTo API docTo spec then `
26. `         return 0; `
27. `      end if; `
28. ` `
29. `      if kTo API docTo spec = 0 or nTo API docTo spec = kTo API docTo spec then `
30. `         return 1; `
31. `      else `
32. `         for j in 1 .. kTo API docTo spec loop `
33. `            top := top * (nTo API docTo spec + 1 - j); `
34. `         end loop; `
35. ` `
36. `         return (top / FactorialTo API docTo specTo body (kTo API docTo spec)); `
37. `      end if; `
38. `   end N_over_KTo API docTo specTo body; `
39. ` `
40. `   procedure Create_Pascal_TriangleTo API docTo spec (HeightTo API docTo spec : Integer := 12; File_NameTo API docTo spec : String := "pascal_triangle.html") is `
41. `      Out_File : File_Type; `
42. ` `
43. `      HTML_Contens : Unbounded_String := Null_Unbounded_String; `
44. `      Lines        : Unbounded_String := Null_Unbounded_String; `
45. `      Item_List    : Unbounded_String := Null_Unbounded_String; `
46. ` `
47. `   begin `
48. `      Put_Line ("begin Create_Pascal_Triangle."); `
49. `      Create (File => Out_File, Name => File_NameTo API docTo spec); `
50. ` `
51. `      HTML_Contens := HTML.TableTo API docTo specTo body (Lines); `
52. ` `
53. `      Put_Line (Out_File, To_String(HTML.HTML_DocumentTo API docTo specTo body (Body_ContensTo API docTo specTo body => HTML_Contens))); `
54. `      Put_Line ("end   Create_Pascal_Triangle."); `
55. `   end Create_Pascal_TriangleTo API docTo specTo body; `
56. ` `
57. `   procedure Create_Factorial_TableTo API docTo spec (HeightTo API docTo spec : Integer := 12; File_NameTo API docTo spec : String := "factorial_table.html") is `
58. ` `
59. `      Out_File     : File_Type; `
60. ` `
61. `      HTML_Contens : Unbounded_String := Null_Unbounded_String; `
62. `      Lines        : Unbounded_String := Null_Unbounded_String; `
63. `      Item_List    : Unbounded_String := Null_Unbounded_String; `
64. ` `
65. `   begin `
66. `      Put_Line ("begin Create_Create_Factorial_Table."); `
67. `      Create (File => Out_File, Name => File_NameTo API docTo spec); `
68. ` `
69. `      Item_List := HTML.ItemTo API docTo specTo body ("n") & HTML.ItemTo API docTo specTo body ("n!"); `
70. `      Lines := Lines & HTML.LineTo API docTo specTo body(Item_List); `
71. ` `
72. ` `
73. `      for n in 0..12 `
74. `      loop `
75. `         Item_List :=  HTML.ItemTo API docTo specTo body ( integer'image(n)) & HTML.ItemTo API docTo specTo body ( integer'image(FactorialTo API docTo specTo body(n))); `
76. `         Lines := Lines & HTML.LineTo API docTo specTo body(Item_List); `
77. `      end loop; `
78. ` `
79. `      HTML_Contens := HTML.TableTo API docTo specTo body (Lines); `
80. `      Put_Line (Out_File, To_String(HTML.HTML_DocumentTo API docTo specTo body (Body_ContensTo API docTo specTo body => HTML_Contens))); `
81. ` `
82. `      Put_Line ("end   Create_Create_Factorial_Table."); `
83. `   end Create_Factorial_TableTo API docTo specTo body; `
84. ` `
85. `end MathematicsTo API docTo specTo body; `