Ad
  • Custom User Avatar

    The tests in Ruby are fine. Closing.

  • Custom User Avatar
  • Default User Avatar

    Good question.

    • The divisors of 4 are: 1, 2, & 4 and their sum is 7. Now, 7/4.0 = 1.75.
    • The divisors of 165 are 1, 3, 5, 11, 15, 33, 55 & 165 and their sum is 288. Now, 288/165.0 = 1.7454545454545454

    The two are different. Note that I've used 7/4.0 and not 7/4 because I want a float, not a truncated integer. You can use the following trick: if x = 7 and y = 4, then the ratio is x/(y * 1.0) to get a float. x/y gives an integer.

    Use this logic and you will see that (5,133) cannot be grouped together because 1.2030075187969924 != 1.2, and so on

    The trick here is to use a data structure that keeps track of the ratios you have already found, so that if you come across that ratio again, you ignore because you are only taking the lowest member in any ratio. It's quite simple😊

  • Default User Avatar

    "sıfır" is the correct Turkish spelling; you've used a dotted "i" in the beginning :)

  • Default User Avatar

    2,3,5,7,11,13,17,19

    The list above is a list of primes. The dominant primes in that entire range are 3,5,11,17. Only 11 and 17 are between 6 and 20 and their sum is 28.

    The first dominant prime is always 3, not 11 as you have pointed out.

    To solve this Kata, list all dominant primes up to the upper limit then pick out the ones that are within the range.