Ruby Integer downto() function with example Last Updated : 07 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The downto() function in Ruby returns all the numbers less than equal to number and greater than equal to limit. It iterates the given block, passing in decreasing values from int down to and including limit. If no block is given, an Enumerator is returned instead. Syntax: (number).downto(limit) Parameter: The function takes the integer from which the number starts decreasing. It takes a parameter which is the limit till which the decreasing occurs. It also takes an enumerator. Return Value: The function returns all the numbers less than equal to number and greater than equal to limit. Example #1: Ruby # Initializing the number num1 = 8 # Prints the number down to 0 puts num1.downto(0){| i | print i, " "} # Initializing the number num2 = -8 # Prints the number down to - 8 only since - 6 > -8 puts num2.downto(-6){| i | print i, " "} Output: 8 7 6 5 4 3 2 1 0 8 -8 Example #2: Ruby # Ruby program of Integer downto() function # Initializing the number num1 = 5 # Prints the number down to - 3 puts num1.downto(-3){| i | print i, " "} # Initializing the number num2 = 19 # Prints the number down to 17 puts num2.downto(17){| i | print i, " "} Output: 5 4 3 2 1 0 -1 -2 -3 5 19 18 17 19 Example #3: Ruby # Initializing the number num1 = 5 # Prints the number down to - 3 puts num1.downto(-3) Output: # Comment More infoAdvertise with us Next Article Ruby Integer downto() function with example G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Integer-class Similar Reads Ruby Integer div() function with example The div() function in Ruby returns the integer division of two numbers. Syntax: (number1).div(number2) Parameter: The function needs two numbers number1 and number2, where number1 is the dividend and number2 is the divisor. Return Value: The function returns the integer division of two numbers. Exam 1 min read Ruby Integer divmod() function with example The divmod() function in Ruby returns integer division value and the remainder. Syntax: (number1).divmod(number2) Parameter: The function takes two number number1 and number2 whose integer division and remainder is returned. Return Value: The function returns the integer division value and the remai 1 min read Ruby Integer digits function with example The digits function in Ruby returns the digits place of converting the number to the given base in the parameter. If there is no such parameter is provided, then the default base is taken as 10. Syntax: number.digits(base) Parameter: The function takes the integer whose conversion is to be done. It 1 min read Ruby Integer even? function with example The even? function in Ruby returns a boolean value. It returns true if the number is even, else it returns false. Syntax: number.even? Parameter: The function takes the integer which is to be checked for even or not. Return Value: The function returns a boolean value which determines if the value is 1 min read Ruby Integer chr function with example The chr function in Ruby returns the string containing the character represented by the int's value according to encoding. Syntax: string.chr([encoding]) Parameter: The function takes the integer value whose encoding is to be done. It takes a non-mandatory parameter encoding if encoding is to be don 1 min read Like