msollami

3n+1

Dec 14th, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. cyc[n_Integer, m_Integer] :=
  2. Max@Table[
  3. NestWhileList[
  4. If[OddQ[#], 3 # + 1, #/2] &,
  5. i,
  6. # != 1 &
  7. ] // Length,
  8. {i, n, m}
  9. ]
  10.  
  11. ArrayPlot[
  12. Table[
  13. cyc[x, y],
  14. {x, 1, 6},
  15. {y, 1, 6}
  16. ],
  17. ColorFunction -> "GreenPinkTones"]
Advertisement
Add Comment
Please, Sign In to add comment