is perfect power (v3)

Revision 3 of this benchmark created on


Setup

function isPP1(n) {
      for (var m = 2; m * m <= n; ++ m)
        for (var k = 2; Math.pow(m, k) <= n; ++ k)
          if (Math.pow(m, k) == n) return [m, k];
      return null;
    }
    
    function isPP2(n){
       for(var i = 2 ; i <= Math.sqrt(n) | 0 ; ++i)
      {
         if( n % i == 0)
         {
            var k = Math.round( Math.log(n) / Math.log(i) );
            if( Math.pow(i,k) == n) return [i,k];
         }
      }
      
      return null;
    }
    
    var n = Math.floor(Math.random() * 1e8);

Test runner

Ready to run.

Testing in
TestOps/sec
isPP1
isPP1(n);
ready
isPP2
isPP2(n);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by computerguy103 on
  • Revision 3: published on
  • Revision 4: published by computerguy103 on