Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n r(n)
- -- ------
- 1 1/1
- 2 1/2
- 3 2/1
- 4 1/3
- 5 3/2
- 6 2/3
- 7 3/1
- 8 1/4
- 9 4/3
- 10 3/5
- 11 5/2
- 12 2/5
- 13 5/3
- 14 3/4
- 15 4/1
- 16 1/5
- 17 5/4
- 18 4/7
- 19 7/3
- 20 3/8
- 50 7/12
- 100 7/19
- 1000 11/39
- 3ẋḶŒpḄċ
- ’Ç”/⁸Ç
- 3ẋḶŒpḄċ
- 3ẋ 3, repeated a number of times equal to {the argument}
- Ḷ Map 3 to [0, 1, 2]
- Œp Take the cartesian product of that list
- Ḅ Convert binary (or in this case hyperbinary) to a number
- ċ Count number of occurrences of {the argument} in the resulting list
- ’Ç”/⁸Ç
- ’Ç Helper function (Ç), run on {the input} minus 1 (‘)
- ”/ {Output that to stdout}; start again with the constant '/'
- ⁸Ç {Output that to stdout}; then run the helper function (Ç) on the input (⁸)
- 1_{_@_2$%2*-+}ri*'/
- 1 / (2 * floor(s/t) + 1 - s/t)
- = t / (2 * t * floor(s/t) + t - s)
- = t / (2 * (s - s%t) + t - s)
- = t / (s + t - 2 * (s % t))
- gcd(t, s + t - 2 * (s % t))
- = gcd(t, s - 2 * (s % t))
- = gcd(t, -(s % t))
- = 1
- 1_ e# s=1, t=1
- { e# Loop...
- _@_2$%2*-+ e# s, t = t, s + t - 2 * (s % t)
- }
- ri* e# ...n times
- '/ e# Separate s and t with a /
- (s#t)0=show s++'/':show t
- (s#t)n=t#(s+t-2*mod s t)$n-1
- 1#1
- s=(!!)(1:1:f 0)
- f n=s n+s(n+1):s(n+1):(f$n+1)
- r n=show(s n)++'/':(show.s$n+1)
- r n=show>>=[s!!n,'/',s!!(n+1)]
- L‘Hị⁸Sṭ
- 1Ç¡ṫ-j”/
- 1Ç¡ṫ-j”/ Main link. Argument: n
- 1 Set the return value to 1.
- Ç¡ Apply the helper link n times.
- ṫ- Tail -1; extract the last two items.
- j”/ Join, separating by a slash.
- L‘Hị⁸Sṭ Helper link. Argument: A (array)
- L Get the length of A.
- ‘ Add 1 to compute the next index.
- H Halve.
- ị⁸ Retrieve the item(s) of A at those indices.
- If the index in non-integer, ị floors and ceils the index, then retrieves
- the items at both indices.
- S Compute the sum of the retrieved item(s).
- ṭ Tack; append the result to A.
- XX‚¹GÂ2£DO¸s¦ìì¨}R2£'/ý
- XX‚ # push [1,1]
- ¹G } # input-1 times do
- Â # bifurcate
- 2£ # take first 2 elements of reversed list
- DO¸ # duplicate and sum 1st copy, s(n)+s(n+1)
- s¦ # cut away the first element of 2nd copy, s(n)
- ìì # prepend both to list
- ¨ # remove last item in list
- R2£ # reverse and take the first 2 elements
- '/ý # format output
- # implicitly print
- FT+"@:qtPXnosV47]xhh
- FT+ % Implicitly take input n. Add [0 1] element-wise. Gives [n n+1]
- " % For each k in [n n+1]
- @:q % Push range [0 1 ... k-1]
- tP % Duplicate and flip: push [k-1 ... 1 0]
- Xn % Binomial coefficient, element-wise. Gives an array
- os % Number of odd entries in that array
- V % Convert from number to string
- 47 % Push 47, which is ASCII for ''
- ] % End for each
- x % Remove second 47
- hh % Concatenate horizontally twice. Automatically transforms 47 into ''
- % Implicitly display
- x,s=input(),[1,1]
- for i in range(x):s+=s[i]+s[i+1],s[i+1]
- print`s[x-1]`+"/"+`s[x]`
- s=lambda x:int(x<1)or x%2 and s(x/2)or s(-~x/2)+s(~-x/2)
- lambda x:`s(x)`+"/"+`s(x+1)`
- s=lambda x:x<1 or x%2 and s(x/2)or s(-~x/2)+s(~-x/2)
- lambda x:`s(x)`+"/"+`s(x+1)`
- f=(i,n=0,d=1)=>i?f(i-1,d,n+d-n%d*2):n+'/'+d
- 11,`│;a%τ@-+`nk'/j
- 11,`│;a%τ@-+`nk'/j
- 11 push 1, 1
- ,`│;a%τ@-+`n do the following n times (where n is the input):
- stack: [t s]
- │ duplicate the entire stack ([t s t s])
- ; dupe t ([t t s t s])
- a invert the stack ([s t s t t])
- % s % t ([s%t s t t])
- τ multiply by 2 ([2*(s%t) s t t])
- @- subtract from s ([s-2*(s%t) s t])
- + add to t ([t+s-2*(s%t) t])
- in effect, this is s,t = t,s+t-2*(s%t)
- k'/j push as a list, join with "/"
- 1i:"tt@TF-)sw@)v]tGq)V47bG)Vhh
- f=function(n)ifelse(n<3,1,ifelse(n%%2,f(n/2-1/2)+f(n/2+1/2),f(n/2)))
- g=function(n)f(n)/f(n+1)
- define(s,`ifelse($1,1,1,eval($1%2),0,`s(eval($1/2))',`eval(s(eval(($1-1)/2))+s(eval(($1+1)/2)))')')define(r,`s($1)/s(eval($1+1))')
- ->n{s=t=1;n.times{s,t=t,s+t-2*(s%t)};"#{s}/#{t}"}
- &01$n"/"on;
- &?!:@}:{:@+@%2*-&1-:
- function f(i)S=[1 1];for(j=1:i/2)S=[S S(j)+S(j+1) (j+1)];end;printf("%d/%d",S(i),S(i+1));end
- n=>{Func<int,int>s=_=>_;s=m=>1==m?m:s(m/2)+(0==m%2?0:s(m/2+1));return$"{s(n)}/{s(n+1)}";};
- n =>
- {
- Func<int,int> s = _ => _; // s needs to be set to use recursively. _=>_ is the same byte count as null and looks cooler.
- s = m =>
- 1 == m ? m // s(1) = 1
- : s(m/2) + (0 == m%2 ? 0 // s(m) = s(m/2) for even
- : s(m/2+1)); // s(m) = s(m/2) + s(m/2+1) for odd
- return $"{s(n)}/{s(n+1)}";
- };
- ([,'/',])&":&([:+/2|]!&i.-)>:
- f =: ([,'/',])&":&([:+/2|]!&i.-)>:
- f 1
- 1/1
- f 10
- 3/5
- f 50
- 7/12
- f 100x
- 7/19
- f 1000x
- 11/39
- (s={1,1};n=1;a=AppendTo;t=ToString;Do[a[s,s[[n]]+s[[++n]]];a[s,s[[n]]],#];t@s[[n-1]]<>"/"<>t@s[[n]])&
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement