Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

4 of 10
added 7 characters in body
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

C (gcc), (削除) 110 (削除ここまで) (削除) 104 (削除ここまで) 98 bytes

t;d;p;r;f(a,l)int*a;{for(r=p=1;l--;){for(t=0;!t;)for(t=d=++p;--d>1;)t=t&&p%d;r*=pow(p,*a++);}r=r;}

Try it online!

Inputs an array of prime exponents and its length \$l\$ and returns the product of the first \$l\$ primes to those exponents.

Explanation

t;d;p;r;f(a,l)int*a;{ // function taking an array of 
 // ints and its length l
 for(r=p=1;l--;){ // loop over the array elements 
 // setting the product r and 
 // the previous prime to 1 
 for(t=0;!t;) // loop until we find the next 
 // prime, t will flag this 
 for(t=d=++p;--d>1;) // set t to truthy, d to p 
 // bumped, bump d down and loop 
 // while d is >= 2 
 t=t&&p%d; // t remains truthy as long as 
 // p has no divisors 
 r*=pow(p,*a++); // once we've found the next 
 // prime multiply r by it 
 // to the power of the current 
 } // value in a 
 d=r; // return r
} // 
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

AltStyle によって変換されたページ (->オリジナル) /