Skip to content

Instantly share code, notes, and snippets.

@bitmappergit
Last active August 18, 2017 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitmappergit/ac5de02b16b53f7bddb84f7b284bc712 to your computer and use it in GitHub Desktop.
Save bitmappergit/ac5de02b16b53f7bddb84f7b284bc712 to your computer and use it in GitHub Desktop.
#set variables for counting
n = 1_i64
x = 1_i64
y = 1_i64
loop do
n = x+1
puts "---start---"
puts n #this prints the current iteration number and the start comment
y = n
puts "---start---"
until n == 1 #this actually does the equasion until n becomes 1
if n.even?
n = n/2
puts n #this prints the current result after doing n/2
else
n = (n*3)+1
puts n #this prints the current result after doing (n*3)+1
end
end
puts "----end----"
puts y #this prints the current iteration number and the end comment
puts "----end----"
x = x+1
sleep (0.01)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment