6 kyu
Find Numbers with Same Amount of Divisors
298 of 915raulbc777
Description:
The integers 14
and 15
are contiguous (i.e. the difference between them is 1
) and have the same number of divisors:
14 ----> 1, 2, 7, 14 # (4 divisors)
15 ----> 1, 3, 5, 15 # (4 divisors)
The next pair of contiguous integers with this property is 21
and 22
:
21 -----> 1, 3, 7, 21 # (4 divisors)
22 -----> 1, 2, 11, 22 # (4 divisors)
We have 8
pairs of integers below 50
having this property, they are:
[ [2, 3], [14, 15], [21, 22], [26, 27], [33, 34], [34, 35], [38, 39], [44, 45] ]
Let's see now the integers that have a difference of 3
between them. There are 7
pairs below 100
:
[ [2, 5], [35, 38], [55, 58], [62, 65], [74, 77], [82, 85], [91, 94] ]
Let's name:
- diff, the difference between two integers, next and prev, (
diff = next - prev
) - nMax, an upper bound of the range.
We need a function that receives two integer parameters, diff and nMax, and outputs the count of pairs of integers that fulfill this property, all of them being strictly smaller than nMax.
So, for the examples detailed above:
(diff = 1, nMax = 50) -----> 8
(diff = 3, nMax = 100) -----> 7
Happy coding!!!
Algorithms
Mathematics
Similar Kata:
Stats:
Created | Sep 10, 2015 |
Published | Sep 10, 2015 |
Warriors Trained | 3513 |
Total Skips | 286 |
Total Code Submissions | 5623 |
Total Times Completed | 915 |
Python Completions | 298 |
Ruby Completions | 48 |
JavaScript Completions | 227 |
CoffeeScript Completions | 6 |
Java Completions | 171 |
C# Completions | 67 |
Clojure Completions | 24 |
Haskell Completions | 27 |
Rust Completions | 34 |
Go Completions | 36 |
C++ Completions | 61 |
Total Stars | 94 |
% of votes with a positive feedback rating | 92% of 203 |
Total "Very Satisfied" Votes | 175 |
Total "Somewhat Satisfied" Votes | 22 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 9 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |