Hailstone sequence: Difference between revisions

→‎{{header|Picat}}: Added subsection. Added {{out}}
No edit summary
(→‎{{header|Picat}}: Added subsection. Added {{out}})
Line 7,480:
nl.</lang>
 
{{out}}
Output:
<pre>H27:
len = 112
Line 7,486:
 
Longest sequence < 100_000:
[maxLen = 351,maxN = 77031]</pre>
</pre>
 
===Mode-directed tabling===
 
If we just want to get the length of the longest sequence - and are not forced to use the same Hailstone function as for the H27 task - then this version using model -directed tabling is faster than longest_seq/1: 0.055s vs 0.127s. (Original idea by Neng-Fa Zhou.)
<lang Picat>go2 =>
time(max_chain(MaxN,MaxLen)),
Line 7,509 ⟶ 7,508:
Len=Len1+1.
</lang>
 
 
 
=={{header|PicoLisp}}==
495

edits