Advertisement
johnpentyrch

second

May 24th, 2020
1,987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.51 KB | None | 0 0
  1. -module(second).
  2.  
  3. -export([perimeter/2,hypotenuse/2,area/2]).
  4.  
  5. hypotenuse(A,B) ->
  6.     %The square on the hypotenuse is equal to the sum of the square on the other two sides
  7.     %To get the hypotenuse we take the square root
  8.     math:sqrt(first:square(A)+first:square(B)).
  9.    
  10.  
  11. perimeter(A,B) ->
  12.     %perimeter is the sum of all side. We know sort sides A, B
  13.     %we can calculate the other side as it is the hypotenuse
  14.     A+B+hypotenuse(A,B).
  15.  
  16. area(A,B) ->
  17.     %area is half of height times width (It is half a rectangle!)
  18.     A*B/2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement