title: Better way to write nested if-else statements
body: <p>What is a most Scala way to write the following piece of logic?</p>
  
  <pre><code>def collatzAlgorithm(target: Int): Int = {
      if (target % 2 == 0) {
        val new_target = target / 2
        if (new_target == 1) {
          new_target
        } else {
          if (new_target % 2 != 0) {
            new_target * 3 + 1
          } else {
            new_target
          }
        }
      } else {
        target
      }
    }
  </code></pre>
  
  <p>Thanks!!!!</p>