buggy

⇠ Back to Blog:Sandbox
Nothing here
julia> while n!=1
           global counter+=1
           print("$(n)\u2192")
           if n%2==0
               global n÷=2
           else
               n=3n+1
           end
       end
       println("1.")

15→46→23→70→35→106→53→160→80→40→20→10→5→16→8→4→2→1.
julia> function collatz(n)
           global counter=0;
           while n!=1
               counter+=1;
               print("$(n)\u2192")
               if n%2==0
                   n÷=2
               else
                   n=3n+1
               end
           end
           println("1. ($(counter) steps)")
       end
collatz (generic function with 1 method)

julia> collatz(24)
24→12→6→3→10→5→16→8→4→2→1. (10 steps)

Gotcha troublemaker! The escaping $() sequence. Should be the escaping $() sequence. Nothing here either {|class="collapsible collapsed" style="font-size:90%; width: 100%; clear:both; text-align: center;border: 1px solid;" |- style="background-color: IndianRed; color:White;" !

''Table of Contents''
[[Wolverhampton_Scientific_Computing|Crash Course on Scientific Computing]] |- | # [[WLP VI/Computers|Computers]] # [[WLP VI/OS|Operating Systems]] # [[WLP VI/Software|Software]] # [[WLP VI/TeX|$\TeX$ and $\LaTeX$]]

  1. Computation
  2. Computer Programming
  3. Julia
  4. Plotting
  5. Numbers
  6. Random numbers
  7. Algorithms–the idea
  8. Algorithms–applications
  9. Root finding
  10. Linear Equations
  11. Interpolation and Extrapolation
  12. Fitting
  13. Integrals
  14. Derivatives
  15. Ordinary Differential Equations
  16. Differential calculus of vector fields
  17. Partial Differential Equations
  18. Finite elements and finite volumes
  19. Fourier and DFT
  20. Chaos and fractals
  21. Fun problems

|}