Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 1 -> 2
- 2 3 -> 28,27
- 3 1 -> 4,19
- 3 4,5 -> 381,70
- 1 9.379 -> 18.758
- 0 48 -> 1
- ÷2µØP*÷!
- ç×*@
- ÷2µØP*÷! - Link 1: n, r
- ÷2 - n / 2
- µ - monadic chain separation
- ØP - π (3.141592653589793)
- * - exponentiate: π^(n/2)
- ! - Pi(n/2): Gamma(n/2 + 1)
- ÷ - divide: π^(n/2) / Gamma(n/2 + 1)
- ç×*@ - Main link: n, r
- ç - call last link (1) as a dyad: π^(n/2) / Gamma(n/2 + 1)
- *@ - exponentiate with reversed @rguments: r^n
- × - multiply: r^n * π^(n/2) / Gamma(n/2 + 1)
- Pi^(a=.5#)/a!#2^#&
- N[Pi^(#/2)/Gamma[#/2 + 1] #2^#] &
- Pi^(.5#)/Gamma[.5# + 1] #2^# & (* replace exact with approximate numbers*)
- Pi^(.5#)/(.5#)! #2^# & (* n! == Gamma[n + 1] *)
- Pi^(a=.5#)/a! #2^# & (* replace repeated .5# *)
- Pi^(a=.5#)/a!#2^#& (* remove whitespace *)
- function(n,r)pi^(n/2)/gamma(n/2+1)*r^n
- function(n,r)c(1,pi,4/3*pi)[n]*r^n
- 0%r=1
- 1%r=2*r
- n%r=2*pi*r^2/n*(n-2)%r
- n%r=(max 1$1-(-1)**n)*(2*pi)^(floor$n/2)*r**n/product[n,n-2..1.1]
- d=(n,r)=>r**n*(n<2?n+1:Math.PI*(n<3?1:4/3))
- 3:^[2P4*P/3]*1hi)
- 3: % Push array [1 2 3]
- % STACK: [1 2 3]
- ^ % Take r implicitly, and raise it to [1 2 3] element-wise
- % STACK: [3 9 27]
- [2P4*P/3] % Push array [2 pi 4*pi/3]
- % STACK: [3 9 27], [2 pi 4*pi/3]
- * % Multiply element-wise
- % STACK: [6 28.2743 113.0973]
- 1h % Append 1
- % STACK: [6 28.2743 113.0973, 1]
- i) % Input n and use it as modular index into the array. Display implicitly
- % STACK: 28.2743
- v 0 r=1
- v 1 r=2*r
- v n r=2*pi*r*r*v(n-2)r/n
- let v 0 r=1
- v 1 r=2*r
- v n r=2*pi*r*r*(v(n-2)r)/n
- (define(v d r)(match d[0 1][1(* 2 r)][_(/(* 2 pi r r(v(- d 2)r))d)]))
- (define(v d r)
- (match d
- [0 1]
- [1 (* 2 r)]
- [_ (/ (* 2 pi r r (v (- d 2) r) )
- d)]
- ))
- (v 1 1)
- (v 2 3)
- (v 3 1)
- (v 3 4.5)
- (v 1 9.379)
- (v 0 48)
- 2
- 28.274333882308138
- 4.1887902047863905
- 381.7035074111599
- 18.758
- 1
- @a=1..2;push@a,6.283/$_*@a[$_-2]for 2..($b=<>);say$a[$b]*<>**$b
- {import math._;(n,r)=>pow(r,n)*Seq(1,2,Pi,Pi*4/3)(n)}
- { //define a block, the type of this is the type of the last expression, which is a function
- import math._; //import everything from math, for pow and pi
- (n,r)=> //define a function
- pow(r,n)* //r to the nth power multiplied by
- Seq(1,2,Pi,Pi*4/3)(n) //the nth element of a sequence of 1, 2, Pi and Pi*4/3
- }
- (n,r)=>[1,r+r,a=Math.PI*r*r,a*r*4/3][n]
- from math import*
- f=lambda n,r:n*r*2*(n<2or pi*r/n/n*(f(n-2,r)or 1))
- from math import*
- f=lambda n,r:1*(n<1)or r*2*(n<2)or 2*pi*r*r/n*f(n-2,r)
- from math import*
- lambda n,r:pi**(n/2)*r**n/gamma(n/2+1)
- #N,R::((if (< N 2) ((? (!= 0 N) (* 2 R) 1)) ((/ (* (* (* (* (f (- N 2) R) 2)
- 3.1416) R) R) N))))
- % n-circle.lithp
- (
- (def f #N,R::((if (< N 2) ((? (!= 0 N) (* 2 R) 1)) ((/ (* (* (* (* (f (- N 2) R) 2) 3.1416) R) R) N)))))
- (print (f 1 1))
- (print (f 2 3))
- (print (f 3 1))
- (print (f 3 4.5))
- (print (f 1 9.379))
- (print (f 0 48))
- )
- #./run.js n-circle.lithp
- 2
- 28.274333882308138
- 4.1887902047863905
- 381.7035074111598
- 18.758
- 1
- {1$_[2dP]*<f*,:)-2%./1+:*}
- { e# Begin block: stack holds d r
- 1$_[2dP]*< e# Build a list which repeats [2 pi] d times and take the first d elements
- f* e# Multiply each element of the list by r
- ,:)-2% e# Build a list [1 ... d] and take every other element starting at the end
- ./ e# Pointwise divide. The d/2 elements of the longer list are untouched
- 1+:* e# Add 1 to ensure the list is non-empty and multiply its elements
- }
Add Comment
Please, Sign In to add comment