Results 1 to 3 of 3
  1. #1
    james12 is offline Banned
    Join Date
    Jun 2014
    Rep Power

    Post need help with RECURSION?

    We have triangle made of blocks. The topmost row has 1 block, the next row down has 2 blocks, the next row has 3 blocks, and so on. Compute recursively (no loops or multiplication) the total number of blocks in such a triangle with the given number of rows.

    triangle(0) → 0
    triangle(1) → 1
    triangle(2) → 3

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    The Netherlands
    Rep Power

    Default Re: need help with RECURSION?

    This is not Rent-a-coder™, you know. Show some effort in cracking this "problem", and so will we. Post your code, error messages, stacktraces, and a specific description of what the problem is. Hint: "it doesn't work" is not a good description.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: need help with RECURSION?

    At row #i are i blocks; on top of that row is a triangle with T(i-1) blocks, so T(i) == i+T(i-1). Row #0 has 0 blocks.


    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Recursion
    By allaudin in forum Forum Lobby
    Replies: 2
    Last Post: 07-21-2013, 04:59 PM
  2. Need help with recursion
    By Playboytrey in forum New To Java
    Replies: 2
    Last Post: 04-29-2011, 01:36 AM
  3. recursion and tail-recursion differences
    By OptimusPrime in forum New To Java
    Replies: 2
    Last Post: 12-28-2009, 06:26 PM
  4. Recursion
    By kathyla18 in forum New To Java
    Replies: 2
    Last Post: 04-09-2009, 02:26 AM
  5. Recursion
    By jachandru in forum New To Java
    Replies: 1
    Last Post: 01-24-2009, 12:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts