#!/usr/bin/env ruby input = gets.chomp.to_i length = 1 pos = 0 after0 = 0 50_000_000.times do |num| pos += input pos %= length pos += 1 after0 = (num + 1) if pos == 1 length += 1 end p after0