Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:35:56+00:00 2026-06-12T19:35:56+00:00

I’m a newbie and I’m trying to code the following factorial series in python

  • 0

I’m a newbie and I’m trying to code the following factorial series in python to calculate the first matching number in a series within a finite range.
kd×d×(d−1)×⋯×(d−k+1)d×d×⋯d=k(d−1)!dk(d−k)!
so the expected value for the number needed for a match is
∑k=1d(k+1)k(d−1)!dk(d−k)!.

Due to the size of the numbers it errors:
OverflowError: long int too large to convert to float
So I’m using logs but still getting an error. Wondering if anyone has an good idea on this.

 m = 365
  q = 1
  a=[]
  for x in range(q,m):
    #y = y + x*(1/365)
    #####y = y + (factorial(x)/(factorial(m-x)*(exponent(m,x))))
    a.append((log((factorial(m))/exponent(m,x)))*log((q+x)/m))
    #y = [(m-x)*factorial(m-x)/m]
    #print ("x: ",x,"   y: ",y)
  #return "a:",a,"  product-sum:",[a*a for a in a]
  return sum(a)

Sorry I see the equation above isn’t clear. Here’s what I’m trying to get at:
http://en.wikipedia.org/wiki/Birthday_problem#Average_number_of_people

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:35:57+00:00Added an answer on June 12, 2026 at 7:35 pm

    EDIT: Just realized – I don’t think logs are going to help you out much here in the first place: you are trying to compute a sum, and logs aren’t very friendly with sums (they’re good for products).

    The link you give suggests another approach (the formula immediately after the one you cite) which should avoid large numbers if you compute in the right order. But the accumulation of rounding errors might affect the result. In code

    m = 365 
    ans = 0
    for x in range(0,m-1):
      tmp = 1
      for y in range(0,x):
        tmp *= (M-y)/M
      ans += tmp
    return ans
    

    That said, using an asymptotic formula like the one given is probably a better way to compute this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.