7 kyu

How many twos?

569 of 1,586Nmistrata
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • PetitLu117 Avatar

    Description should be language agnostic. Here is a suggestion for a fix (reworded).

    I also made the description language-agnostic using KaTeX in my Lua translation but feel free to use the following or another one if you prefer.

    preview

    Task

    Write a function that returns the power of 2 in the prime factorization of a positive integer (>= 1).

    Examples

    24 should return 3 -> 24 = 2**3 * 3
    17280 should return 7 -> 17280 = 2**7 * 3**3 * 5
    
    copy-paste

    # Task
     Write a function that returns the power of `2` in the prime factorization of a positive integer (`>= 1`).
    # Examples
    ```
    24 should return 3 -> 24 = 2**3 * 3
    17280 should return 7 -> 17280 = 2**7 * 3**3 * 5
    ```

  • PetitLu117 Avatar

    Lua translation ! made description language-agnostic + used KaTeX

  • asbeforee Avatar

    This comment has been hidden.

  • saudiGuy Avatar
  • ejini战神 Avatar

    Description should be language-agnostic

  • lchewy Avatar

    This comment has been hidden.

  • chaseklingel3 Avatar

    This comment has been hidden.

  • taw Avatar

    No test for 0

  • NaMe613 Avatar

    Clojure translation kumited.

  • Darnor Avatar

    Issues with the C# version.

    Replace the given code with:

    public class Kata
    {
      public static int TwoCount(long n)
      {
        // your code here
      }
    }
    

    And also replace the given tests with:

    using NUnit.Framework;
    
    [TestFixture]
    public class Tests
    {
      [Test]
      [TestCase(24, Result=3)]
      [TestCase(17280, Result=7)]
      [TestCase(222222222222, Result=1)]
      [TestCase(256, Result=8)]
      [TestCase(1, Result=0)]
      [TestCase(2, Result=1)]
      [TestCase(7, Result=0)]
      [TestCase(84934656, Result=20)]
      public static int FixedTest(long num)
      {
        return Kata.TwoCount(num);
      }
    }
    
  • Jotha Avatar

    C# translation kumited.

  • hilary Avatar

    "n will always be a positive integer greater than or equal to 1." in the description isn't very clear as you never use 'n' in the description. 'n' could be the input number or the number of 2's in the factorization.