Results 1 to 3 of 3
  1. #1
    james12 is offline Member
    Join Date
    Jun 2014
    Posts
    37
    Rep Power
    0

    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
    Location
    The Netherlands
    Posts
    1,088
    Rep Power
    4

    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
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    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.

    solved.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

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