Skip to content

Commit 72c6381

Browse files
committed
Add Function definition: Colatz Conjecture
1 parent 0b3cc93 commit 72c6381

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mathics/web/media/js/inout.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ function showGallery() {
196196
'Sum[2 i + 1, {i, 0, 10}] (* Sum of 1st n odd numbers (n+1)**2 *)',
197197
'n = 8; 2 ^ # & /@ Range[0, n] (* Powers of 2 *)',
198198
'Total[%] (* Sum is 2 ^ n - 1 *)',
199+
200+
'(**** Functions ****)',
201+
'(* Colatz Conjecture https://oeis.org/A006577 *)',
202+
'f[n_] := Module[{a=n, k=0}, While[a!=1, k++; If[EvenQ[a], a=a/2, a=a*3+1]]; k]',
203+
'Table[f[n], {n, 4!}]',
199204
'(**** Symbolic Manipulation ****)',
200205
'Apart[1 / (x^2 + 5x + 6)]',
201206
'Cancel[x / x ^ 2]',

0 commit comments

Comments
 (0)