Skip to main content

New answers tagged

0 votes

Odds for second smallest prime factor

PARI/GP, 102 bytes use the formula in A342479 (numerators) and A342480 (denominators) $$ f(n) = \left\{ \begin{array}{l} p = \text{prime}(n), \\ q = \{ q \in \mathbb{N} \,|\, q < p \wedge \text{...
138 Aspen's user avatar
  • 5,811
2 votes

Odds for second smallest prime factor

Ruby, 75 bytes ->n{a=1;(2...n).sum{|x|a*=1-1r/x*z=1[(2...x).sum{|y|1[x%y]}];1r/~-x*z}*a/n} Try it online! How? Wait for Arnauld to post a Javascript solution, ...
G B's user avatar
  • 21.9k
3 votes

Odds for second smallest prime factor

Wolfram Language (Mathematica), 51 bytes D[Times@@(1+(x-1)/Array[p=Prime,#-1]),x]/p@#/.x->0& Try it online! An unnamed function taking a 1-indexed integer <...
Greg Martin's user avatar
  • 15.7k
5 votes

Odds for second smallest prime factor

K (ngn/k), 25 24 bytes {+/%/|x,y,*/\y-1}.1`pri\ Try it online! Uses the formula from Bubbler's Jelly answer. ...
att's user avatar
  • 20.4k
5 votes

Odds for second smallest prime factor

PARI/GP, 40 bytes p->prod(q=1,p-1,1+isprime(q)*x/q)'/p%x++ Attempt This Online! Based on the formula in @Bubbler's Jelly answer. Takes the derivative of the ...
alephalpha's user avatar
4 votes

Odds for second smallest prime factor

JavaScript (ES6), 66 bytes Takes a prime number and returns the probability as a floating point number. ...
Arnauld's user avatar
  • 192k
3 votes

Odds for second smallest prime factor

Charcoal, 28 bytes Nθ≔Φ…²θΠ﹪ι…²ιηI∕↨÷Π⊖η⊖η¹×θΠη Attempt This Online! Link is to verbose version of code. Explanation: Port of @Bubbler's formula. ...
Neil's user avatar
  • 170k
6 votes

Odds for second smallest prime factor

05AB1E, 9 bytes !Lfζ1èQÅA Port of @emanresuA's Vyxal answer. Try it online or verify the smaller test cases (the larger ones time out). Explanation: ...
Kevin Cruijssen's user avatar
4 votes

Odds for second smallest prime factor

05AB1E, 13 bytes <ÅP<Ð>/Ps/Os/ Attempt This Online! Directly computes the answer. This seems way too long. Roughly equivalent to ...
Command Master's user avatar
8 votes

Odds for second smallest prime factor

Jelly, 11 bytes ÆRµṖ’P-ƤS÷P Try it online! Let \$P = p_1, p_2, \cdots, p_k\$ be the list of primes strictly less than the input prime \$p\$. Then, the chance that ...
Bubbler's user avatar
  • 76.1k
5 votes

Odds for second smallest prime factor

Jelly, 11 bytes !ÆfQḊḢƲ€ċ÷! Try It Online! Same idea as the Vyxal answer, which is the observation that we can just look at 1 ...
hyper-neutrino's user avatar
  • 42.4k
9 votes

Odds for second smallest prime factor

Vyxal, 8 bytes ¡ƛǏḣh;=ṁ Try it Online! -2 thanks to tsh, -1 thanks to lyxal. ...
emanresu A's user avatar
  • 37.9k

Top 50 recent answers are included