After creating the PF, when I was entering the Fizz_Buzz problem again in Ruby, I have deepened my understanding a little, so I will leave it as a memorandum.
The player sits in a circle. The first player says the number "1". The next player speaks the next number of the previous player. However, if it is divisible by 3, it is "Fizz" (in the case of Bizz Buzz, it is "Bizz"), if it is divisible by 5, it is "Buzz", and if it is divisible by both (that is, it is divisible by 15), it is "Fizz Buzz" (Bizz Buzz). If you have to say "Bizz Buzz") instead of a number. Those who make a mistake or hesitate will be dropped out. Posted from Wiki: https://ja.wikipedia.org/wiki/Fizz_Buzz
Writing this programmatically requires conditional branching (if statements, etc.) and repetition (for statements, etc.), so it is often a practice problem for beginners.
def fizz_buzz(number) if number % 15 == 0 puts "fuzz_buzz" elsif number % 5 == 0 puts "buzz" elsif number % 3 == 0 puts "fuzz" else puts number.to_s end end puts "Please enter a number greater than or equal to 1" for i in 1..5 do print fizz_buzz(gets.to_i) end
Look closely at the following programs on the controller
def show @user = User.find(params[:id]) end