Learning recursion with hailstone seqence
- From: "DAVID B MORGAN" <lepton2@xxxxxxxxxxx>
- Date: Thu, 16 Nov 2006 21:47:21 GMT
I'm playing with the hailstone sequence. My function will
need to iterate millions of times to process the data. I have two questions:
1. Can this function be optimised ? (approx 2^67 iterations are neccessary
on current dataset)
2. How can I test huge numbers (like 2^1000) --- Int64 can't handle it
function hailstone(x:int64):int64;
begin
if odd(x) then result:=x*3+1
else result:=x shr 1;
if result<>1 then hailstone(result) ;
end;
*****************************************************************
* I'm neither a programmer nor a math whiz so keep it as simple as
possible *
*****************************************************************
Thanks
DBM
.
- Follow-Ups:
- Have you tried recursion with Ackerman?
- From: Heinrich Wolf
- Re: Learning recursion with hailstone seqence
- From: DAVID B MORGAN
- Re: Learning recursion with hailstone seqence
- From: Tom de Neef
- Re: Learning recursion with hailstone seqence
- From: Tom de Neef
- Re: Learning recursion with hailstone seqence
- From: Maarten Wiltink
- Re: Learning recursion with hailstone seqence
- From: Andreas Koch
- Have you tried recursion with Ackerman?
- Prev by Date: Out of system resources
- Next by Date: Re: Learning recursion with hailstone seqence
- Previous by thread: Out of system resources
- Next by thread: Re: Learning recursion with hailstone seqence
- Index(es):