need help with recursive function 
Author Message
 need help with recursive function

I need to write a recursive function that will take a number entered by the
user, process it and then display the number of characters that number has.
Please help. thank you.


Wed, 18 Jun 1902 08:00:00 GMT  
 need help with recursive function
Go right ahead!  When you've finished, you can post it here for us to admire.
[I'm assuming you are NOT asking us to do your homework for you, as you know
that not only violates the spirit of this newsgroup, but will be of absolutely
no benefit to you, since you won't learn anything by handing in someone else's
work ...].

Bob Schor
Pascal Enthusiast

Quote:

> I need to write a recursive function that will take a number entered by the
> user, process it and then display the number of characters that number has.
> Please help. thank you.



Wed, 18 Jun 1902 08:00:00 GMT  
 need help with recursive function

Quote:

>> I need to write a recursive function that will take a number entered by the
>> user, process it and then display the number of characters that number has.
>> Please help. thank you.

I can offer some valuable help - don't use recursion to do that!
Jud McCranie


Wed, 18 Jun 1902 08:00:00 GMT  
 need help with recursive function
This is probably a school assignment, and is probably designed to teach "recursive
thinking" (or what mathematicians call "induction").  Now, once one knows how to
solve a (recursive) problem recursively, one can also learn when to use iteration,
or other techniques.

Bob Schor

Quote:


> >> I need to write a recursive function that will take a number entered by the
> >> user, process it and then display the number of characters that number has.
> >> Please help. thank you.

> I can offer some valuable help - don't use recursion to do that!
> Jud McCranie



Wed, 18 Jun 1902 08:00:00 GMT  
 need help with recursive function

Quote:

>This is probably a school assignment, and is probably designed to teach "recursive
>thinking" (or what mathematicians call "induction").  Now, once one knows how to
>solve a (recursive) problem recursively, one can also learn when to use iteration,
>or other techniques.

But it is bad uses of recursion like this that give people the
wrong idea, because it is much better done iteratively.  And
iteration should come before recursion.
Jud McCranie


Wed, 18 Jun 1902 08:00:00 GMT  
 need help with recursive function
Sorry.. I'm an Italian boy so my English couldn't be very perfect.
This problem can be solved by "recursive thinking" because it can be showed
as:

function chars_of_number(n: word): byte;
begin
    if n<10 then chars_of_number:=1 else
chars_of_number:=1+chars_of_number(n div 10);
end;

so the function becomes a recursive-one. The teacher cauld have assigned it
to force the student to think in recursive mode and teach him to apply this
method every time he likes...

I'm sorry for showing an example in pascal code, but it was the only method
to tell my idea about teacher's assignment.

Jud McCranie ha scritto nel messaggio ...

Quote:

>>This is probably a school assignment, and is probably designed to teach
"recursive
>>thinking" (or what mathematicians call "induction").  Now, once one knows
how to
>>solve a (recursive) problem recursively, one can also learn when to use
iteration,
>>or other techniques.

>But it is bad uses of recursion like this that give people the
>wrong idea, because it is much better done iteratively.  And
>iteration should come before recursion.
>Jud McCranie



Tue, 15 Apr 2003 07:57:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Need help with recursive functions in Turbo Pascal 7.0

2. Need Help! Recursive programming: shortest route

3. Recursive power of 2 function

4. Recursive power of 2 function

5. Recursive function

6. Stack Size with recursive functions

7. Need : Recursive file search/directory search

8. Recursive Procedure expert needed

9. Search function need help

10. Need help with DbiPutField and similiar functions.

11. Need help in function and array!

12. Need help porting function to Free Pascal

 

 
Powered by phpBB® Forum Software