wesvirus 94f3018cec Update 'Add-Subtract-Multiply-or-Divide/code.cpp' 4 vuotta sitten
..
README.md d2a2ba9e15 first commit 4 vuotta sitten
code.cpp 94f3018cec Update 'Add-Subtract-Multiply-or-Divide/code.cpp' 4 vuotta sitten
unitTest.cpp d2a2ba9e15 first commit 4 vuotta sitten

README.md

Add, Subtract, Multiply or Divide?

by Matt tags: math, numbers

Summary

Write a function that takes two numbers and returns if they should be added, subtracted, multiplied or divided to get 24. If none of the operations can give 24, return "Invalid". Examples operation(15, 9) ➞ "added" operation(26, 2) ➞ "subtracted" operation(11, 11) ➞ "Invalid" Notes Only integers are used as test input. Numbers should be added, subtracted,

Instructions

Write a function that takes two numbers and returns if they should be added, subtracted, multiplied or divided to get 24. If none of the operations can give 24, return "Invalid".

Examples

operation(15, 9) ➞ "added"

operation(26, 2) ➞ "subtracted"

operation(11, 11) ➞ "Invalid"

Notes

  • Only integers are used as test input.
  • Numbers should be added, subtracted, divided or multiplied in the order they appear in the parameters.