#
# PYTHON • MyCompiler
# https://[Log in to view URL]
# Teoria das Partições
# Fórmula de Hardy-Ramanujan-Radmacher
#
# 2026 Abril Seg, 27 — Ter, 28
# by
# j
# 

import numpy as np

#
# Algoritmo MDC
# mdc(a,b) via Euclides
# Quarta~Feira 14 Maio 2025
# by
# j
#

# (1) 120/23 = 5 resta 5
# (2) 23/5 = 4 resta 3
# (3) 5/3 = 1 resta 2
# (4) 3/2 = 1 resta 1
# (5) 2/1 = 2 resta 0

def mdc(a,b,p):

  mdc = b
  
  f = True
  
  X = a
  Y = b

  if ( p==1 ):
    
    print(' ')
    print('{'+str(a)+','+str(b)+'}')
    print(' ')
    
  while (f):
    
    if ( p == 1 ):
      
      print(X,'/',Y,end='')
    
    D = int(X/Y)
    r = X % Y
    X = Y
    Y = r

    if ( p == 1 ):
      
      print(' = ',D,' resta ',r)
    
    if (r == 0):
      f = False
    else:
      mdc = r

  if ( p == 1):
    
    print(' ')
    print('mdc('+str(a)+','+str(b)+') = '+str(mdc) )
    
  return mdc

def frm(n,k):
    dif = n - 1/24
    f = np.sinh( ((np.pi/k)*np.sqrt((2/3)*dif)))/np.sqrt(dif)
    return f

def drv(n,k):
    delta = 0.00000000001
    d = (frm(n+delta,k) - frm(n,k))/delta
    return d

def s(h,k):
    sum = 0
    for r in range(1,k):
        sum += (r/k)*( (h*r/k) - np.floor(h*r/k) - 1/2)
    return sum

def A(k,n):
    sum = 0
    for h in range(0,k):
        if (mdc(h,k,0) == 1):
            sum += np.exp( ( s(h,k) - 2*n*h/k )*np.pi*1j )
    return sum

def p(n):
    max = 4
    s = 0
    for k in range(1,max+1):
        print(A(k,n))
        print(drv(n,k))
        s += A(k,n)*np.sqrt(k)*drv(n,k)
        print(s)
        print('---')
    q = (1/(np.pi*np.sqrt(2)))*s
    return q

print('p(100) [ REAL ]      = 190.569.292')
print('p(100) [ RAMANUJAN ] =',p(100))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: