Hacker News new | ask | show | jobs
by j-walker 1572 days ago
Can someone explain to me why in Section 4: Functions they compute Twice by multiplying the number by three then subtracting the number once? Is it just to showcase more math, or is there a detail I'm missing?

> /* Computes double of a number. Works by tripling the number, and then subtracting to get back to double. /

   static int Twice(int num) {

      int result = num * 3;

      result = result - num;

      return(result);**