SHARE
TWEET

Untitled

a guest Dec 18th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import math as m
  2.  
  3. def D(i):
  4.     if i==0:
  5.         return(1)
  6.     else:
  7.         return(0)
  8.  
  9. def d(i,n):
  10.     if i==1:
  11.         if n%6==0:
  12.             return(1)
  13.         else:
  14.             return(0)
  15.     if i>1:
  16.         if n%((i+1)*(i+2))==0:
  17.             return(d(i-1,n)+1)
  18.         else:
  19.             return(d(i-1,n))
  20.  
  21. def p(n):
  22.     S=0
  23.     for i in range(1,n+1):
  24.         for k in range(2,m.floor(m.sqrt(i))+1):
  25.             S=S+(2*D(d(k,i))+D(d(k,i)-1))*(1-D(d(k-1,i)-1))*d(k,i)
  26.     return(1/6+S/(n))
  27.  
  28. for i in range(1,10):
  29.     n=2**i
  30.     print(n,p(n))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top