|
-
Apr 27th, 2006, 12:03 PM
#1
Thread Starter
Junior Member
[RESOLVED] recursion code , rewriting?
sorry if i have posted in wrong place, i dont where else it will fit in
here is example of mod:
17 MOD 7 is 3
72 MOD 15 is 12
i have the following code:
FUNCTION Curiosity(X:Integer;Y:Integer):Integer;
IF Y = 0 THEN
Curiosity = X
ELSE
Output Y and (X MOD Y)
Curiosity = Curiosity(Y,X MOD Y)
ENDIF
END Curiosity
i have to rewrite the above as an iterative algorithm not as recursive.
i am puzzled and would greatly appreciate if someone could attempt this. however i only require it to be small, max about 20 lines, and only need it to use basic vb language, such as the following:
for and next loop, do while, if and end if, mod, etc
once again, i would really appreciate your effort to help me.
-
Apr 27th, 2006, 12:06 PM
#2
Re: recursion code , rewriting?
If it is VB related it should go in ClassicVb.
If it is VBA related it should go in Office Development.
Let me know which it is an I will move this thread to its proper location for you.
Thanks.
-
Apr 27th, 2006, 12:39 PM
#3
Re: recursion code , rewriting?
kazoo: Please check your private messages.
Last edited by Hack; Apr 27th, 2006 at 01:09 PM.
-
Apr 27th, 2006, 01:09 PM
#4
Re: recursion code , rewriting?
In so far as my inquires have gone unanswered, I'm going to make an educated guess based on prior threads from this member, that this is an Excel VBA question.
Moved from the CodeBank.
-
Apr 27th, 2006, 01:19 PM
#5
Re: recursion code , rewriting?
What is the purpose of this function?
What value is it supposed to return? Say for an input value set of 72,15
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Apr 27th, 2006, 01:48 PM
#6
Lively Member
Re: recursion code , rewriting?
This is another example from a test paper (appeared in another post).
See page 7 of the attached.
http://www.ocr.org.uk/OCR/WebSite/Da...Level93039.pdf
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
Apr 27th, 2006, 01:50 PM
#7
Re: recursion code , rewriting?
Thanks, I'll be removing my subscription to this thread then....
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Apr 27th, 2006, 01:56 PM
#8
Addicted Member
Re: recursion code , rewriting?
Have fun!!!!!
VB Code:
Public Function Curiosity(X As Integer, Y As Integer) As Integer
Dim temp As Integer
Do While Y >= 0
If Y = 0 Then
Curiosity = X
Exit Do
Else
MsgBox "Value of Y :" & Y & " " & "Value of X MOD Y :" & (X Mod Y)
temp = Y
Y = X Mod Y
X = temp
End If
Loop
End Function
-
Apr 27th, 2006, 02:35 PM
#9
Thread Starter
Junior Member
Re: recursion code , rewriting?
thank you very much for your help and for putting it in simplistic terms.
-
Apr 27th, 2006, 02:38 PM
#10
Addicted Member
Re: recursion code , rewriting?
my pleasure, then you can mark the thread as resolved.
Thread Tool on upper right
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|