# Tag Info

1

Vyxal, 1 byte I Try it Online! Casts input to int, stripping any decimals.

1

Zephyr, 52 bytes set i to 1 while 1=1 print i,"+" set i to i/2 repeat Try it online! Gotta love built-in rational numbers. For +3 bytes, output with all spaces (no newlines): Try it online!

1

Factor, 33 bytes 1 [ dup "%u+" printf 2 / t ] loop Try it online! 1 Push 1 to the stack. [ ... t ] loop The shortest infinite loop available in Factor. dup "%u+" printf Non-destructively write the prettyprinted form of an object with a "+" afterward. 2 / Divide by two. In Factor, / produces an exact ratio as long as its inputs ...

2

Python 3.7, 228 197 184 bytes Thanks to @LyricLy and friends for helping me golf this down a lot 1e999 stolen from @Quintec's solution m=1e999 g=lambda p:[f(*x)if[]==x*0else x for x in p] def f(l,h): h=min(g(h+[m]));l=max(g(l+[-m]));s=1 while h-l<=1:l*=2;h*=2;s*=2 return-(-h//1+1)/s if h<=0else l*h>=0and(l//1+1)/s Try it online!

1

Stax, 7 bytes â─$∩√Öu Run and debug it same idea as 05AB1E, but Stax has more convenient output here :) Explanation Wi^p"+1/ W loop forever i^ increment counter p print without newline "+1/ print "+1/" without newline 0 Julia, 22 bytes n$d=(l=lcm(d))n./d.=>l Try it online! expects [numerators] $[denominators] outputs an array of pairs : [num1 => den1, num2 => den2,...] could be 20 bytes with the denominator only once in the ouput 0 05AB1E, 9 bytes .¿©¹÷*®δ‚ Input as two separated lists, first the list of denominator, second the list of numerator. Output as a list of pairs of [numerator, denominator]. Try it online or verify all test cases. Explanation: .¿ # Get the Least Common Multiple (LCM) of the first (implicit) input-list of # denominators © # Store ... 1 Clojure, 90 bytes #(loop[x 3 y 5/4](let[z(+(/ 1 x x)y)n numerator](condp = % 1 5(n y)(n z)(recur(inc x)z)))) Try it online! Like many other languages, Clojure has native support for rational fractions, but with an annoying quirk: numerator and denominator functions throw exceptions on integer arguments. If that's not enough, even rational literals of the ... 4 R, 112 bytes x=scan();while({d=prod((1:T)^2);n=sum(d/(1:T)^2);i=1;while((i=i+1)<n)while(!n%%i&!d%%i)n=n/i;x!=F}){T=T+1;F=n};n Try it online! How? x=scan(); # get previous wolstenholme number x while({...do this...;x!=F}) # first 'do this', then check if x is equal to F (initially zero) { # 'do this': d=... 1 Wolfram Language (Mathematica), 29 bytes 0&@@10~MultiplicativeOrder~#& Try it online! 3 Ruby, 58 bytes ->x{r=z=1r;1until[z,z+=(r+=1)**-2]*?_=~/^#{x}.+_(\d+)/;$1} Try it online!

2

Vyxal, 33 30 bytes 1:{›Ȯ?≤|:λ¡²nɾ²/M∑:n¡²ġ/;†^_}Ȯ Try it Online! Let us try to maintain a stack with 2 elements $n$ and $f(n)$ after every step, with $f(n)$ being the required numerator. 1: # Pushes [1, 1] to the stack. { # While... › # Increment the first value of stack -> [n+1, f(n)] Ȯ?≤ # While condition: Is the second value of ...

3

Stax, 15 bytes ┬Z°#¡Lk╢╙°m╕%ºb Run and debug it Reduced from 22 with help from recursive. Explanation {iiGx=!w^G}Z{Ju+Fr { w while result is falsy: ii push iteration index twice G GoTo unclosed curly brace } label: Z push a zero under the index { F for 1..i ...

3

Husk, 14 bytes ←t↓≠⁰mois∫m□İ\ Try it online! or Verify all testcases Explanation ←t↓≠⁰mois∫m□İ\ İ\ infinite list [1,1/2,1/3,... m□ map to squares ∫ cumulative sum mo map to is first integer in string representation (gets numerator) ↓ drop elements till ≠⁰ ...

0

CSASM v2.4.0.1, 123 bytes A function which pops three values from the stack ([N, W, P]) and pushes the result as an f64. The function expects the types of all three values to be f64. .include <stdmath> func a: pop $3 pop$2 pop $1 push$3 dup push $2 swap push$1 mul sub neg swap push 1.0 sub div neg push 0.0 call max ret end Explanation + Full ...

1

Pari/GP, 31 bytes f(W,N,P)=-min(-(P*N-W)$$1-P),0) Try it online! 2 Jelly, (16?) 21 bytes ²€P©:S:g¥® 1Ç⁼¥1#Ḣ‘Ç Try it online! I can't prove that $a(n) \ge n$, but if so this 16 byter works too: ‘²€P©:S:g¥®)ḟRḢ How? ²€P©:S:g¥® - Link 1, get a(n): integer n ²€ - square each (of [1..n])  - last two links as a monad - f(squares): P - product (of the squares) © - (copy to the ... 0 Wolfram Language (Mathematica), 25 bytes 0//.x_/;x+#-##2<x#3:>x+1& Try it online! We can also directly compute the number of needed wins: Wolfram Language (Mathematica), 25 bytes ⌈Ramp[#-##2]/(#3-1)⌉& Try it online! 2 Charcoal, 57 bytes Ｎθ≔⁰η≔⁰ζＷ⁻θζ«≔ηζ⊞υＸ⊕Ｌυ²≔Πυε≔Σ÷ευδＷδ«≔﹪εκδ≔κε»≔÷Σ÷Πυυεη»Ｉη Try it online! Link is to verbose version of code. Explanation: Ｎθ Input the target numerator. ≔⁰η≔⁰ζ Initialise the next and current numerator to zero. Ｗ⁻θζ« Repeat until the current numerator is the target. ≔ηζ Save the next numerator as the current numerator. ⊞υＸ⊕Ｌυ² Add ... 5 JavaScript (ES6), 98 bytes f=(n,i=0)=>(g=(p=!(j=k=++i),q=1)=>j?g(p,q*j*j--):k?g(x=p+q/k/k--,q):q?g(q,p%q):x/p)()-n?f(n,i):g() Try it online! Commented f = ( // f is a recursive function taking: n, // n = input i = 0 // i = counter, initialized to 0 ) => ... 1 Vyxal, 8 bytes λ¹+ɖ⁰≥;ṅ Try it Online! Here's what I managed to come up with. It doesn't seem like anyone else is going to give this a go using Vyxal, so here's my solution. Explained λ¹+ɖ⁰≥;ṅ λ # start a lambda that, given a single argument "n": ¹+ # adds n to the list [wins, matches] ɖ # reduces that list by division ... 2 Ruby, 61 bytes Uses Ruby's Rational type. ->x{w=l=n=k=0r (l=n;k+=1;w+=1/k/k;n=w.numerator)while l!=x n} Try it online! 73 bytes with integers: ->x{d=1 n=l=k=w=0 (l=n;k+=1;w*=k*k;w+=d;d*=k*k;n=w/w.gcd(d))while l!=x n} Try it online! 4 Raku, 54 bytes {first *>_,map *.nude,[\+] map *⁻²,1.FatRat..*} Try it online! [\+] map *⁻², 1.FatRat .. * is the harmonic sequence. The members are of type FatRat, a "fat rational" type that does not degrade to floating point. (I could skip the .FatRat for seven bytes and use ordinary rationals, which give the correct answer for all of ... 5 Haskell, 78… 76 bytes -2 bytes thanks to kops. f n=snd(span(/=n)head.words.show<>scanl1(\i j->i+1/j^2::Rational)[1..])!!1 The relevant function is f, which takes n as a string of digits, and returns the next Wolstenholme number as a string of digits. Try it online! 1 Wolfram Language (Mathematica), 54 bytes (k=1;While[(t=Numerator[++k~HarmonicNumber~2])<=#];t)& Try it online! 8 J, 39 35 30 28 bytes (]{~1+i.~)1*.[:+/\_2^~1+i.,] Try it online! -5 thanks to Bubbler's observation that the numerator is the LCM of the fraction and 1. -2 thanks to Bubbler for a transformation. Note: The approach below relies on the assumption that every Wolstenholme number is greater than or equal its index, which was kindly proved by Greg Martin. [:+/\... 4 MATL, 30 26 bytes 0@:Utptb/swyZd/ht1_)G-]0) Try it online! Explanation 0 % Push 0. This initiallizes the array of numerators  % Do...while @:U % Push [1, 2, 4, ..., n^2] where n is iteration index tp % Duplicate, product. Gives denominator (not reduced) tb % Duplicate, bubble up in stack. Moves copy of [1, 2, 4, ..... 1 Python 3, 126 bytes from math import* def f(n,i=1,k=1): k*=i*i q=sum(k//j**2for j in range(1,i+1)) x=q/gcd(k,q) return x>n and x or f(n,i+1,k) Try it online! Let's find the numerator if the denominator is $1^2 + 2^2 + ... i^2$. The numerator of the $j^{th}$ term will be just the denominator divided by $j^2$. So we add the numerator of all ... 3 Python 2, 120 bytes from fractions import* x=input() k=1 g=0 n=[] while x not in n[:-1]:g+=Fraction(1,k*k);k+=1;n+=[g.numerator] print n[-1] Try it online! fixed thanks to Jonathan Allan 1 Japt, 11 bytes @°*L¨V°*W}a Try it 2 Haskell, 37 bytes (n,w)#p|100*w<p*n=1+(n+1,w+1)#p|1>0=0 Try it online! 1 Charcoal, 202 bytes ＮθＮη≔⁰ζＦ⟦χ⁵¦²⟧Ｗ¬﹪ηι«≦⊕ζ≧÷ιη≧×÷χιθ»¿⊖η«≔χεＷ﹪⊖εη≧×χε≧×÷⊖εηθ≔θδ≔¹ηＷ÷⁻×⊖ε﹪θηδ×εη«≧×χη≔×±δ↨Ｅ↨⊖ηε¹εθ»≔ΦＩ⁺ε÷⁻×⊖ε﹪θηδηκδ»«≔¹ηＷ÷⁺θη⊗η≧×χη≔…9‹θ⁰δ»≔ΦＩ⁺η﹪θηκη≦⁻Ｌ⁺δηζＷ⮌…∨⮌δ0±ζ«≔⁺ιηη≔…⁺ιδＬδδ≔⁰ζ»⭆δ⁺….⁼κζι'⭆η⁺….⁼⁺Ｌδκζι Try it online! Link is to verbose version of code. Takes numerator and denominator on separate lines. Explanation: ＮθＮη Input the ... 3 Jelly, 9 bytes 0+÷/:⁴ʋ1# Try it online! Full program that takes [w, n] on the left and P on the right. How it works 0+÷/:⁴ʋ1# - Main link. Takes [w, n] on the left and P on the right ʋ - Previous 4 links as a dyad f(x, [w, n]): + - Yield [w+x, n+x] ÷/ - Yield (w+x)÷(n+x) ⁴ - Yield P : - Floor divide (w+x)÷(n+x) ... 3 Clojure, 39 bytes #(max(Math/ceil(/(-(* %2%)%3)(- 1%)))0) Try it online! Takes arguments in reverse order compared to the provided test cases ($P, N, W$). 2 Retina 0.8.2, 68 bytes \d+ * \G1 100* 1(?=1*,(1*)%) 1 +^(1*,)(1+\1(1+)) 100*1132_ _ Try it online! Link includes test cases. Takes P as a percentage (including % sign). Explanation: \d+ * Convert W, N and P to unary. \G1 100* Multiply W by 100. 1(?=1*,(1*)%) 1 Multiply N by P. +^(1*,)(1+\1(1+)) While 100W<NP... 100*1132_ increment W ... 3 PowerShell, 44 bytes Every answer of Wasif inspires me to make the right one. Thanks. param(w,n,p)for(;w++/n++-ltp){k++}+k Try it online! 2 Ruby, 34 bytes ->w,n,p{[0,-(w-p*n).div(1-p)].max} Try it online! 4 R, 45 43 42 38 bytes Edit: simultaneous discovery of -1 byte by Kirill L., and then -4 bytes thanks to pajonk function(W,N,P)-min((W-P*N)%/%(1-P),0) Try it online! 2 JavaScript, 44 40 34 bytes f=(w,n,p)=>w/n>=p?0:f(w+1,n+1,p)+1 Takes all three parameters as integers except p which is a decimal. -4 bytes, thanks to @DominicvanEssen -6 bytes, thanks to @Arnauld Try it online 1 Charcoal, 24 bytes ＮθＮηＮζ≔⁰εＷ‹⁺θε×ζ⁺ηε≦⊕εＩε Try it online! Link is to verbose version of code. Explanation: ＮθＮηＮζ Input W, N and P. ≔⁰ε Start with X=0. Ｗ‹⁺θε×ζ⁺ηε Until we reach the desired win percentage... ≦⊕ε ... increment X. Ｉε Output X. A port of @hyper-neutrino's solutions is of course much shorter at 13 bytes: Ｉ⌈⟦⁰±÷⁻×ＮＮＮ⊖θ Try it online! Link ... 2 PowerShell, 51 bytes param(w,n,p)while((w+k)/(n+k)-ltp){k+=1}k Try it online! What? It beat my python answer? oO 4 Jelly, 10 bytes Ḣ_Ḣ×÷’Ċ»0 Try it online! Explanation This uses the same formula as my Python answer: $X\geq\frac{W-PN}{P-1}$ Takes the input as a list of three numbers, $W,N,P$. Ḣ_Ḣ×÷’Ċ»0 Main Link Ḣ W (pops from the list) _ minus Ḣ× N (pops from the list) times the list (now only has P) ÷’ divided by (P - 1) ... 9 Python 3, 35 bytes lambda w,n,p:-min(0,(w-p*n)//(1-p)) Try it online! -4 bytes thanks to pajonk Some simple math: if $X$ is the number of wins we need, then we have: $\frac{W+X}{N+X}\geq P$ $W+X\geq PN+PX$ $X-PX\geq PN-W$ $X(1-P)\geq PN-W$ Since $P<1$, then $1-P>0$, so we can divide from both sides without division by zero or flipping ... 1 Python 3, 55 bytes f=lambda w,n,p,c=0:(w+c)/(n+c)>=p and c or f(w,n,p,c+1) Try it online! Simple recursion, I am beaten by few minutes.... 4 05AB1E, 13 15 11 bytes ∞<.Δ¹+.«/²@ Try it online! Why aren't I using Vyxal? Because I'm leaving the chance for others so they can claim the bounty. +2 due to bug fix :( but -4 thanks to @ovs Explained (old) ∞0š.ΔD²+s¹+s/³@ ∞0š.Δ # get the first integer n where: D²+s¹+s/ # (wins + n) / (matches + n) ³@ # >= ... 5 Wolfram Language (Mathematica), 142 128 125 bytes {Clear@r;_r:=e<(e=10#2~GCD~e);e=10;l=1//.o_?r:>10o,n=l#;{}//.g_/;!r@n:>(For[j=0;r@n=l--,!e∣n,n-=#2,j++];n/=10;j<>g),r@n-l}& Try it online! Input [n, d]. Implements the division algorithm. Returns {r, QD, q} | r, where QD is a StringJoin of digits and r is a power of ten, representing \\... 1 Pyth, 34 bytes phAcQ\.s[" + ("/sHKisHJ*TlH\//JK$$ Not that proud of this but that output format was getting to my head Try it online!

0

Vyxal, 20 19 bytes I₌I-ƒJ% + (%/%)$% Try it Online! It's convoluted because of the handling of the output format Explained (old) :I₌₴-ƒ\/j...$%, :I # int(input) ₌₴- # print(top, end=""), input - int(input) [gets the fractional part] ƒ # Turn the decimal into a simplified fraction \/j #...

5

Jelly, 12 bytes :g/æl/;g/}ɗ/ Try it online! Takes input as [[list of numerators], [list of denominators]]. +2 bytes to take input as a list of [numerator, denominator] pairs How it works :g/æl/;g/}ɗ/ - Main link. Takes a pair of lists [N, D] on the left / - Columnwise reduce by: g - GCD : - Divide, reducing the fractions ...

0

Vyxal, 6 5 bytes ‡Ė+ḭƒ Try it Online! I added foldr lol. Explained ‡Ė+ḭƒ ‡Ė+ # lambda x, y: 1 / x + y ḭ # reduce input by ↑, going right-to-left ƒ # fractionify the result

Top 50 recent answers are included