Skip to main content
added 1139 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

Explanation

t;r;p;f(n,B){                           // function taking two int inputs
                                        // n and B
             for(r=p=1;                 // loop over prime factors p of n
                                        // also init return value r to 1
                       n/++p;           // loop while p<=n also bump p
                             r&=t/n<=B) // at the end of each loop check that
                                        // the current prime power factor of
                                        // n (t/n) is less than or equal to B
                  for(                  // loop to strip n of all its
                                        // prime factors p
                      t=n;              // save copy of n in t before 
                                        // removing all p factors
                          n%p<1;        // loop while p is a factor of n
                                n/=p);  // reduce n by p  
             t=r;                       // return r  
}

Explanation

t;r;p;f(n,B){                           // function taking two int inputs
                                        // n and B
             for(r=p=1;                 // loop over prime factors p of n
                                        // also init return value r to 1
                       n/++p;           // loop while p<=n also bump p
                             r&=t/n<=B) // at the end of each loop check that
                                        // the current prime power factor of
                                        // n (t/n) is less than or equal to B
                  for(                  // loop to strip n of all its
                                        // prime factors p
                      t=n;              // save copy of n in t before 
                                        // removing all p factors
                          n%p<1;        // loop while p is a factor of n
                                n/=p);  // reduce n by p  
             t=r;                       // return r  
}
added 6 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C (gcc), 6666 64 bytes

d;r;k;ft;r;p;f(n,B){for(r=k=1;nr=p=1;n/++k;r&=d<=B++p;r&=t/n<=B)for(d=1;n%k<1;nt=n;n%p<1;n/=k=p)d*=k;k=r;;t=r;}

Try it online!Try it online!

Takes two integers \$n\$ and \$B\$ as input and returns \$1\$ if \$n\$ is \$B\$-powersmooth or \$0\$ otherwise.

C (gcc), 66 bytes

d;r;k;f(n,B){for(r=k=1;n/++k;r&=d<=B)for(d=1;n%k<1;n/=k)d*=k;k=r;}

Try it online!

Takes two integers \$n\$ and \$B\$ as input and returns \$1\$ if \$n\$ is \$B\$-powersmooth or \$0\$ otherwise.

C (gcc), 66 64 bytes

t;r;p;f(n,B){for(r=p=1;n/++p;r&=t/n<=B)for(t=n;n%p<1;n/=p);t=r;}

Try it online!

Takes two integers \$n\$ and \$B\$ as input and returns \$1\$ if \$n\$ is \$B\$-powersmooth or \$0\$ otherwise.

added 119 characters in body
Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46

C (gcc), 66 bytes

d;r;k;f(n,bB){for(r=k=1;n/++k;r&=d<=b++k;r&=d<=B)for(d=1;n%k<1;n/=k)d*=k;k=r;}

Try it online!Try it online!

Takes two integers \$n\$ and \$B\$ as input and returns \$1\$ if \$n\$ is \$B\$-powersmooth or \$0\$ otherwise.

C (gcc), 66 bytes

d;r;k;f(n,b){for(r=k=1;n/++k;r&=d<=b)for(d=1;n%k<1;n/=k)d*=k;k=r;}

Try it online!

C (gcc), 66 bytes

d;r;k;f(n,B){for(r=k=1;n/++k;r&=d<=B)for(d=1;n%k<1;n/=k)d*=k;k=r;}

Try it online!

Takes two integers \$n\$ and \$B\$ as input and returns \$1\$ if \$n\$ is \$B\$-powersmooth or \$0\$ otherwise.

Source Link
Noodle9
  • 20.3k
  • 3
  • 21
  • 46
Loading