Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ ¹ ² ³ °
 

You are not logged in.
Post a replyTopic review (newest first)
i wrote this python code, which from wolfram says that its supposed to return the factorial of any positive value (i probably messed up somewhere), integer or not: Code:from math import * def double_factorial(n): if int(n) == n: n = int(n) if [0,1].__contains__(n): return 1 a = (n&1) + 2 # checks if its even or odd and starts the a value at 2 or 3 b = 1 while a<=n: b*=a a+= 2 return float(b) else: return factorials(n/2) * 2**(n/2) *(pi/2)**(.25 *(1+cos(n * pi))) # go to the next definition def factorials(n): return pi**(.5 * sin(n*pi)**2) * 2**(n + .25 * (1 + cos(2*n*pi))) * double_factorial(2*n) # go back up the problem is , say i input pi to 6 decimal places. 2*n will not become a float with 0 as its decimals any time soon, so the equation turns out to be Code:pi**(.5 * sin(n*pi)**2) * 2**(n + .25 * (1 + cos(2*n*pi))) * double_factorial(loop(loop(loop(...))))) how would i stop the recursion and still get the answer? 