Results 1 to 12 of 12
Thread: recursive function
- 09-02-2010, 12:11 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
- 09-02-2010, 12:18 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 09-02-2010, 12:27 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
i got as far as writing a recursive function that is extremly simple
BEGIN count(num)
IF num<3
print num
count (n+1)
END IF
END Count
but i cant seem to adapt the aspects of this algorithim into it any help/ pointers would be great
- 09-02-2010, 12:30 PM #4
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
it would be greatly appreciated if you could step me through the process of changing the algorithim to a recursive function. iam new to software development so please bare with me
- 09-02-2010, 01:38 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
is their anyone who can help me out all i need is two or three lines of code and my problem is solved, please help me out
- 09-02-2010, 01:55 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
You recursive method should have a structure like this:
Notice the recursive call at the end of the function body; you should pass the correct parameter values (those can be found/deduced from the original WHILE body).Java Code:BEGIN program(num1, num2) IF (num2 == 0) RETURN num1 return program( ... , ...)
kind regards,
Jos
- 09-02-2010, 02:02 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
thank you very much appreciated
- 09-02-2010, 02:30 PM #8
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
BEGIN program (num1, num2)
declare num3 as int
IF(num2 == 0) RETURN num1
return program(num1/num2) to num3
(num1 to num2)
(num2 to num3)
ENDIF
Return num1
END program
hopefully this will work if not give me one more pointer in the right direction:)
cheers jayden
- 09-02-2010, 02:45 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 09-02-2010, 02:49 PM #10
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
what happened to num 3
- 09-02-2010, 02:54 PM #11
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 09-02-2010, 03:00 PM #12
Member
- Join Date
- Sep 2010
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
basic help with Recursive
By syntrax in forum New To JavaReplies: 3Last Post: 12-15-2009, 06:19 AM -
Possible? Callback function passed as arguments to another function
By TreyAU21 in forum Advanced JavaReplies: 3Last Post: 12-04-2009, 03:08 PM -
Recursive Counting
By zlwilly in forum New To JavaReplies: 1Last Post: 01-29-2009, 08:42 PM -
Understanding this recursive function
By LifeWithJava in forum New To JavaReplies: 3Last Post: 12-30-2008, 05:26 AM -
Help with recursive function in java
By cachi in forum Advanced JavaReplies: 2Last Post: 07-31-2007, 06:51 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks