All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Binomial and Floor Difference Crossed Division Determination (Posted on 2023-06-03) Difficulty: 3 of 5
Consider this function:
F(n, p) = nCp - ⌊n/p⌋
where n is a positive integer and p is a prime number.

Is F(n, p) always divisible by p?
If so, prove it.
If not, provide a counterexample.

Notes: nCp is the number of combinations of n elements taken p at a time. It is also known as Binomial Coefficient and read as "n choose p".
• ⌊m⌋ is equal to floor of m which is the greatest integer less than or equal to m

No Solution Yet Submitted by K Sengupta    
Rating: 2.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution | Comment 1 of 3
[Edit:  this comment is incorrect due to rounding error; see Charlie's note.   The comb(61,23) ends in 700 rather than 696.
Thus I do not have a counterexample which disproves the conjecture]

F(61, 23) is the first failure of the conjecture.   [incorrect]

F(61, 23) = 37539612570341696 - 2 = 37539612570341694
but 37539612570341694 / 23 = 1632157068275725.8

----
def isprime(n):
    '''check if integer n is a prime'''
    n = abs(int(n))
    if n < 2:
        return False
    if n == 2: 
        return True    
    if not n & 1: 
        return False
    for x in range(3, int(n**0.5)+1, 2):
        if n % x == 0:
            return False
    return True

primes = [p for p in range(100000) if isprime(p)]

def fact(n):
    if n == 1 or n == 0:
        return 1
    ans = 1
    for i in range(n):
        ans *= (i+1)
    return ans

factorials = [fact(i) for i in range(1000)]    
def myComb(m,a):
    """ combination m things a at a time  """
    a = min(a, m-a)
    num = 1
    # den = 1
    for i in range(a):
        num *= (m-i)
        # den *= (i+1)
    return int(num/factorials[a]) # use this if you make a list factorials
    # return int(num/fact(a))
    
# F(n, p) = nCp - ⌊n/p⌋
def f(n,p):
    return  myComb(n,p) - int(n/p)

big = 65
for n in range(2,big):
    smallprimes = []
    for s in primes:
        smallprimes.append(s)
        if s > n:
            break
    for p in smallprimes:
        x = f(n,p)
        if (x)%p != 0:
            print(n,p,x, (x)%p, x/p)

Edited on June 3, 2023, 3:26 pm
  Posted by Larry on 2023-06-03 08:33:34

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (11)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information