TiddlyWiki5/editions/tw5.com/tiddlers/test-collatz.tid

20 lines
519 B
Plaintext

created: 20240415102801809
modified: 20240425142244830
tags:
title: test-collatz
type: text/vnd.tiddlywiki
\procedure collatz(n)
<% if [<n>match[1]] %>
1
<% elseif [<n>remainder[2]match[1]] %>
<<n>> - ^^@@<<parent-ancestorcount>>@@^^ → <$transclude $variable="collatz" n = {{{ [<n>multiply[3]add[1]] }}}/>
<% else %>
<<n>> - ^^@@<<parent-ancestorcount>>@@^^ → <$transclude $variable="collatz" n = {{{ [<n>divide[2]] }}}/>
<% endif %>
\end
<<set_UNSAFE_max_widget_tree_depth 5000>>
<<collatz 9780657630>>