Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 937 online users. » 0 Member(s) | 933 Guest(s) Bing, Yandex, Applebot, DuckDuckGo
|
Latest Threads |
SELECT statement with MS ...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:35 PM
» Replies: 0
» Views: 1,507
|
SELECT statement with the...
Forum: MS Access SQL Tutorials
Last Post: Qomplainerz
07-27-2023, 03:31 PM
» Replies: 0
» Views: 874
|
Creating hyperlinks in HT...
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 01:23 PM
» Replies: 0
» Views: 1,253
|
What's new in HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:48 PM
» Replies: 0
» Views: 942
|
What is HTML5?
Forum: HTML5 Tutorials
Last Post: Qomplainerz
07-27-2023, 12:43 PM
» Replies: 0
» Views: 846
|
Neck isometric exercises
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:44 AM
» Replies: 0
» Views: 1,198
|
Shoulder shrug
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 769
|
Neck retraction
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:43 AM
» Replies: 0
» Views: 754
|
Neck flexion and extensio...
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 857
|
Neck rotation
Forum: Exercises
Last Post: Qomplainerz
07-27-2023, 11:42 AM
» Replies: 0
» Views: 820
|
|
|
Greatest common divisor and least common multiple in Ruby |
Posted by: Qomplainerz - 02-28-2021, 09:13 AM - Forum: Ruby 3 Tutorials, exercises and examples
- No Replies
|
 |
To get the greatest common divisor and the least common multiple of 2 numbers at the same time
we can use the gcd_lcm function instead of gcd and lcm in two separated functions.
In this example we want to know the greatest common divisor
and the least common multiple of 36 and 60.
Quote:num1 = 36
num2 = 60
gcd_lcm = num1.gcd_lcm(num2)
puts gcd_lcm
This will print 12 and 180 in two lines on the screen.
|
|
|
Floor and precisions in Ruby |
Posted by: Qomplainerz - 02-28-2021, 08:40 AM - Forum: Ruby 3 Tutorials, exercises and examples
- No Replies
|
 |
Example 1
Let's assume our number is 12.12 and we want to print the floor without any precision:
Quote:puts 12.12.floor
This will print 12 on the screen
Example 2
Let's assume our number is 12.12 and we want to print the floor with a precision of 1 decimal place:
Quote:puts 12.12.floor(1)
This will print 12.1 on the screen
Example 3
Let's assume our number is 12.12 and we want to print the floor with a precision of 2 decimal places:
Quote:puts 12.12.floor(2)
This will print 12.12 on the screen
|
|
|
Ceil and precisions in Ruby |
Posted by: Qomplainerz - 02-28-2021, 08:35 AM - Forum: Ruby 3 Tutorials, exercises and examples
- No Replies
|
 |
Example 1:
Let's assume our number is 1.1 and we want to print the ceil without any precision:
Quote:puts 1.1.ceil
This will print 2 on the screen, because 1.1 is rounded up to the next whole number.
Example 2:
Let's assume our number is 1.1 and we want to print the ceil with a precision of 1 decimal place:
Quote:puts 1.1.ceil(1)
This will print 1.1 on the screen, because 1.1 is rounded to the nearest 1st. decimal place.
Example 3:
Let's assume our number is 1.1 and we want to print the ceil with a precision of 2 decimal places:
Quote:puts 1.1.ceil(2)
This will print 1.11 on the screen, because 1.1 is rounded to the nearest 2nd decimal place.
|
|
|
|