from math import factorial as MF
#s people in room.
#s/365 days will end, expected people is s+1.
ev = 0
for s in range(1, 366):
i = MF(365) * s * (s+1) / ((365**(s+1)) * MF(365-s))
ev += i
print(ev)
24.61658589459887
#2p+s people in room.
#p pairs of people in room that share a birthday.
#s single people in room, meaning no one else in room has their birthday.
#p/365 days will end, expected people is s+2p+1.
ev = 0
for p in range(1, 366):
for s in range(0, 366-p):
i = MF(365) * MF(2*p+s) * (s+2*p+1) / ((365**(s+2*p+1)) * MF(365-s-p) * MF(p-1) * MF(s) * (2**p))
ev += i
print(ev)
88.73891765060254