Skip to main content

Posts

Showing posts with the label %

4th July Independence Day: Learning the sq rt

- Learnt from kata how to use Random.new & rand(1..6) https://stackoverflow.com/questions/198460/how-to-get-a-random-number-in-ruby - Learnt that = is used for assignment and == for comparison in ruby. - learnt what Math.sqrt(x) is. - return true/false stops the program and will not print any put statements after - The ternary operator works in a way that is like puts 1 ? 2 : 3 There has to be a method in front - This is an interesting algorithm for looking at determining the sqrt using maths. Quite amazing but impractical for more than 10 million. https://www.codecademy.com/en/forum_questions/511126448c0a9ee18600695f - Learnt that modulus % is very interesting. x % 1 == 0 but if x is a float, then it would be false instead of true.