7 kyu

Smooth numbers

132 of 1,277GiacomoSorbi

Description:

The concept of "smooth number" is applied to all those numbers whose prime factors are lesser than or equal to 7: 60 is a smooth number (2 * 2 * 3 * 5), 111 is not (3 * 37).

More specifically, smooth numbers are classified by their highest prime factor and your are tasked with writing a isSmooth/is_smooth function that returns a string with this classification as it follows:

  • 2-smooth numbers should be all defined as a "power of 2", as they are merely that;
  • 3-smooth numbers are to return a result of "3-smooth";
  • 5-smooth numbers will be labelled as "Hamming number"s (incidentally, you might appreciate this nice kata on them);
  • 7-smooth numbers are classified as "humble number"s;
  • for all the other numbers, just return non-smooth.

Examples:

isSmooth(16) === "power of 2"
isSmooth(36) === "3-smooth"
isSmooth(60) === "Hamming number"
isSmooth(98) === "humble number"
isSmooth(111) === "non-smooth"
isSmooth(16) == "power of 2"
isSmooth(36) == "3-smooth"
isSmooth(60) == "Hamming number"
isSmooth(98) == "humble number"
isSmooth(111) == "non-smooth"
is_smooth(16) == "power of 2"
is_smooth(36) == "3-smooth"
is_smooth(60) == "Hamming number"
is_smooth(98) == "humble number"
is_smooth(111) == "non-smooth"
is_smooth(16) == "power of 2"
is_smooth(36) == "3-smooth"
is_smooth(60) == "Hamming number"
is_smooth(98) == "humble number"
is_smooth(111) == "non-smooth"
is_smooth(16) == "power of 2"
is_smooth(36) == "3-smooth"
is_smooth(60) == "Hamming number"
is_smooth(98) == "humble number"
is_smooth(111) == "non-smooth"
is_smooth(16) == "power of 2"
is_smooth(36) == "3-smooth"
is_smooth(60) == "Hamming number"
is_smooth(98) == "humble number"
is_smooth(111) == "non-smooth"
isSmooth(16) == "power of 2"
isSmooth(36) == "3-smooth"
isSmooth(60) == "Hamming number"
isSmooth(98) == "humble number"
isSmooth(111) == "non-smooth"

The provided input n is always going to be a positive number > 1.

Number Theory

Stats:

CreatedJun 24, 2018
PublishedJun 29, 2018
Warriors Trained3222
Total Skips52
Total Code Submissions4113
Total Times Completed1277
JavaScript Completions290
Ruby Completions63
Crystal Completions8
Python Completions422
C++ Completions182
C Completions132
Java Completions213
C# Completions79
Total Stars46
% of votes with a positive feedback rating93% of 283
Total "Very Satisfied" Votes246
Total "Somewhat Satisfied" Votes33
Total "Not Satisfied" Votes4
Total Rank Assessments4
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • GiacomoSorbi Avatar
  • raulbc777 Avatar
  • NunoOliveira Avatar
  • KataSideKick Avatar
  • clcraig Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad