jeudi 15 septembre 2016

How to find row number of a chosen number in a triangular number sequence?

I'm trying to find the row number in a chosen square in this(http://ift.tt/2cylMan). For instance if I choose getRow(17); I would get answer = 6. I don't even know where to begin. Can someone point me in the right direction?

class RowShelf{
   public static void main(String[] args) {
      getRow(24); // ans = 7
      getRow(17); // ans = 6
   }

   public static int getRow(int sq){

  }
}

Aucun commentaire:

Enregistrer un commentaire