Simple Fun #21: Number Of Clans
Description:
Task
Let's call two integers A and B friends if each integer from the array divisors is either a divisor of both A and B or neither A nor B. If two integers are friends, they are said to be in the same clan. How many clans are the integers from 1 to k, inclusive, broken into?
Example
For divisors = [2, 3] and k = 6
, the output should be 4
The numbers 1 and 5 are friends and form a clan, 2 and 4 are friends and form a clan, and 3 and 6 do not have friends and each is a clan by itself. So the numbers 1 through 6 are broken into 4 clans.
Input/Output
[input]
integer arraydivisors
A non-empty array of positive integers.
Constraints:
2 ≤ divisors.length < 10, 1 ≤ divisors[i] ≤ 10
.[input]
integerk
A positive integer.
Constraints:
5 ≤ k ≤ 50
.[output]
an integer
Similar Kata:
Stats:
Created | Jan 24, 2017 |
Published | Jan 24, 2017 |
Warriors Trained | 742 |
Total Skips | 57 |
Total Code Submissions | 636 |
Total Times Completed | 266 |
JavaScript Completions | 88 |
C# Completions | 50 |
Python Completions | 136 |
Ruby Completions | 23 |
Total Stars | 5 |
% of votes with a positive feedback rating | 86% of 92 |
Total "Very Satisfied" Votes | 73 |
Total "Somewhat Satisfied" Votes | 12 |
Total "Not Satisfied" Votes | 6 |
Total Rank Assessments | 6 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |