5 kyu

Generating Numbers From Prime Factors I

333 of 353raulbc777

Description:

Given a list of prime factors, primesL, and an integer, limit, try to generate in order, all the numbers less than the value of limit, that have all and only the prime factors of primesL

Example

primesL = [2, 5, 7]
limit = 500
List of Numbers Under 500          Prime Factorization
___________________________________________________________
           70                         [2, 5, 7]
          140                         [2, 2, 5, 7]
          280                         [2, 2, 2, 5, 7]
          350                         [2, 5, 5, 7]
          490                         [2, 5, 7, 7]

There are 5 of these numbers under 500 and the largest one is 490.

Task

For this kata you have to create the function count_find_num(), that accepts two arguments: primesL and limit, and returns the amount of numbers that fulfill the requirements, and the largest number under limit.

The example given above will be:

primesL = [2, 5, 7]
limit = 500
count_find_num(primesL, val) == [5, 490]

If no numbers can be generated under limit then return an empty list:

primesL = [2, 3, 47]
limit = 200
find_nums(primesL, limit) == []

The result should consider the limit as inclusive:

primesL = [2, 3, 47]
limit = 282
find_nums(primesL, limit) == [1, 282]

Features of the random tests:

number of tests = 200
2 <= length_primesL <= 6 // length of the given prime factors array
5000 <= limit <= 1e17
2 <= prime <= 499  // for every prime in primesL

Enjoy!

Algorithms
Data Structures
Mathematics
Dynamic Programming

Stats:

CreatedApr 21, 2017
PublishedApr 23, 2017
Warriors Trained1075
Total Skips77
Total Code Submissions2262
Total Times Completed353
Python Completions333
COBOL Completions6
Go Completions13
Rust Completions18
D Completions5
Total Stars48
% of votes with a positive feedback rating93% of 68
Total "Very Satisfied" Votes60
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes1
Total Rank Assessments6
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • raulbc777 Avatar
  • anter69 Avatar
  • lechevalier Avatar
  • kazk Avatar
  • Voile Avatar
  • akar-0 Avatar
  • saudiGuy Avatar
Ad