Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
15
Task/Arithmetic-Integer/Elixir/arithmetic-integer.elixir
Normal file
15
Task/Arithmetic-Integer/Elixir/arithmetic-integer.elixir
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Function to remove line breaks and convert string to int
|
||||
get_int = fn msg -> IO.gets(msg) |> String.strip |> String.to_integer end
|
||||
|
||||
# Get user input
|
||||
a = get_int.("Enter your first integer: ")
|
||||
b = get_int.("Enter your second integer: ")
|
||||
|
||||
IO.puts "Elixir Integer Arithmetic:\n"
|
||||
IO.puts "Sum: #{a + b}"
|
||||
IO.puts "Difference: #{a - b}"
|
||||
IO.puts "Product: #{a * b}"
|
||||
IO.puts "True Division: #{a / b}" # Float
|
||||
IO.puts "Division: #{div(a,b)}" # Truncated Towards 0
|
||||
IO.puts "Remainder: #{rem(a,b)}" # Sign from first digit
|
||||
IO.puts "Exponent: #{:math.pow(a,b)}" # Float, using Erlang's :math
|
||||
Loading…
Add table
Add a link
Reference in a new issue