View Single Post
  #5 (permalink)  
Old 05-01-2008, 08:51 PM
Magic101 Magic101 is offline
Member
 
Join Date: May 2008
Posts: 3
Magic101 is on a distinguished road
Quote:
Originally Posted by Zosden View Post
Heres a nice template for recursion

Code:
public <modifier> recusiveAlg(You need some sort of parameter) { if(some sort of stopping criteria) { return something; } else { return recursiveAlg(your parameter - 1) } }
Try to do this with Fibonacci numbers

hint: Fibonacci's numbers are the previous fib number + the one before the pervious fib number.
hmmm correct me if i'm wrong but isn't it already implemented in the main function?

Code:
if (n > 0) { int[][] pascal = Rows(n); for (int[] row : pascal) { for (int v : row) System.out.print(v + " "); System.out.println("");
all Rows has to do is to generate the array somehow to decide the row number...

Last edited by Magic101 : 05-01-2008 at 08:58 PM.
Reply With Quote