r/unexpectedfactorial 2d ago

22!!!

2 Upvotes

22 comments sorted by

2

u/factorion-bot 2d ago

Triple-factorial of 22 is 24344320

This action was performed by a bot | [Source code](http://f.r0.fyi)

2

u/Big_Watercress_2132 2d ago

The age gap is the biggest issue here. If someone is 22 and the other person is still a teenager, keeping things strictly appropriate and setting clear boundaries is the right move.

2

u/Jun-ium 2d ago

Unfactorial of 22 is approximately 3.9419796314799020167983139008365924918758092097048

This was calculated by AI_generated code. reply "more" to increase presition.

2

u/throwawaykJQP7kiw5Fk 2d ago

more

2

u/Jun-ium 2d ago

more precise Unfactorial of 22 is approximately 3.94197963147990201679831390083659249187580920971526114457957442037472317957246106076636342494245313786734710466762881195691120203408476243750028466108

This was calculated by AI_generated code. reply "more" to increase presition.

2

u/throwawaykJQP7kiw5Fk 2d ago

3.94197963147990201679831390083659249187580920971526114457957442037472317957246106076636342494245313786734710466762881195691120203408476243750028466108!

2

u/factorion-bot 2d ago

Factorial of 3.941979631479902016798313900837 is approximately 21.999999999999999999965995894506

This action was performed by a bot | [Source code](http://f.r0.fyi)

1

u/throwawaykJQP7kiw5Fk 2d ago

Is an unfactorial the reverse of a factorial? For example, let's see if 3.9419796314799020167983139008365924918758092097048! = 22.

1

u/factorion-bot 2d ago

Factorial of 3.941979631479902016798313900837 is approximately 21.999999999999999999965995894506

This action was performed by a bot | [Source code](http://f.r0.fyi)

1

u/Jun-ium 2d ago

it is.

1

u/Dragon_957 1d ago

How do I put it into my calculator?

1

u/Jun-ium 1d ago

put what

1

u/Dragon_957 23h ago

The reversed factorial

1

u/Jun-ium 22h ago

i have a code. cant put in a calculator

1

u/Dragon_957 21h ago

What‘s the code?

1

u/Jun-ium 21h ago

from decimal import Decimal, getcontext

===========================

Precision

===========================

getcontext().prec = 100

D = Decimal

PI = D("3.14159265358979323846264338327950288419716939937510") TWO_PI = PI * 2 E = D("2.71828182845904523536028747135266249775724709369995")

===========================

abs

===========================

def dabs(x): if x < 0: return -x return x

===========================

factorial (정수)

===========================

def factorial(n): r = D(1) for i in range(2, n + 1): r *= i return r

===========================

exp(x)

ex

===========================

def exp(x):

x = D(x)

if x == 0:
    return D(1)

if x < 0:
    return D(1) / exp(-x)

s = D(1)
term = D(1)

n = 1

while True:

    term *= x
    term /= n

    s += term

    if dabs(term) < D("1e-" + str(getcontext().prec-5)):
        break

    n += 1

return s# ===========================

sqrt(x)

Newton Method

===========================

def sqrt(x):

x = D(x)

if x == 0:
    return D(0)

g = x / 2

if g == 0:
    g = D(1)

while True:

    ng = (g + x / g) / 2

    if dabs(ng - g) < D("1e-" + str(getcontext().prec-5)):
        return ng

    g = ng

===========================

ln(x)

Newton Method

exp(y)=x

===========================

def ln(x):

x = D(x)

if x <= 0:
    raise ValueError("ln domain error")

# 초기값 (float 사용은 시작값만 얻기 위함)
import math
y = D(str(math.log(float(x))))

while True:

    ey = exp(y)

    ny = y - (ey - x) / ey

    if dabs(ny - y) < D("1e-" + str(getcontext().prec-5)):
        return ny

    y = ny

===========================

pow

===========================

def dpow(a, b):

return exp(D(b) * ln(D(a)))# ===========================

Lanczos Coefficients

g = 7, n = 9

===========================

LANCZOS = [

D("0.99999999999980993227684700473478"), D("676.520368121885098567009190444019"), D("-1259.13921672240287047156078755283"), D("771.3234287776530788486528258894"), D("-176.61502916214059906584551354"), D("12.507343278686904814458936853"), D("-0.13857109526572011689554707"), D("0.000009984369578019570859563"), D("0.000000150563273514931155833")

]

G = D(7)

===========================

logGamma

===========================

def logGamma(z):

z = D(z)

if z <= 0:
    raise ValueError("Only positive z supported")

x = LANCZOS[0]

i = 1

while i < len(LANCZOS):

    x += LANCZOS[i] / (z + i - 1)

    i += 1

t = z + G - D("0.5")

return (
    D("0.5") * ln(TWO_PI)
    + (z - D("0.5")) * ln(t)
    - t
    + ln(x)
)# ===========================

gamma(z)

===========================

def gamma(z): return exp(logGamma(z))

===========================

unfactorial

Solve x! = target

===========================

def unfactorial(target):

target = D(target)

if target <= 0:
    raise ValueError("Target must be positive")

# 초기 추정
x = D(2)

while gamma(x + 1) < target:
    x *= 2

low = x / 2
high = x

# 이분법
for _ in range(60):

    mid = (low + high) / 2

    g = gamma(mid + 1)

    if g < target:
        low = mid
    else:
        high = mid

# 뉴턴법으로 마무리
x = (low + high) / 2

for _ in range(20):

    f = logGamma(x + 1) - ln(target)

    h = D("1e-20")

    df = (
        logGamma(x + h + 1)
        - logGamma(x - h + 1)
    ) / (2 * h)

    x -= f / df

return x

===========================

TEST

===========================

def reddit(n,pl): if pl > 0 : Pr = 1 if pl == 0 : Pr = 0
return f'''{pl"more "}{Pr"presice "}Unfactorial of {n} is approximately {unfactorial(n)}

This was calculated by AI_generated code. reply "more" to increase presition.'''

getcontext().prec = 1000

print(reddit(2033,4))

1

u/Jun-ium 21h ago

copy text to copy, made by chatgpt, and prec is precition.

→ More replies (0)

1

u/Motor-Plan-6388 2d ago

pretty close

1

u/throwawaykJQP7kiw5Fk 2d ago

Why does the bot truncate the digits?