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

Home > Numbers > Sequences
Integers only (Posted on 2023-09-25) Difficulty: 2 of 5
Given:
f(x)=Sum[x/n!] for all positive integers n, where the [] brackets define the integer part of x (e.g. [pi]=3)

What is x, if f(x)=1215

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution | Comment 5 of 6 |
x can be anywhere on the interval [709,710)
 or 709 + a where 0 <= a < 1
Since the title says "integers only", if this applies to x, then x=709.
But if the title applies only to f(x), then x can be anywhere in that interval.

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

def sumf(x):
    ans = 0 
    for n in range(1,100):
        ans += int(x/fact(n))
    return ans

lo = 500
hi = 1000
error = 10000
while error > 0:
    guess = (lo+hi)/2
    f = sumf(guess)
    if f > 1215:
        hi = guess
        error = abs(f - 1215)
    elif f < 1215:
        lo = guess
        error = abs(f - 1215)
    elif f == 1215:
        print('The answer is ', guess)
        error = abs(f - 1215)

for d in range(200):
    i = 708+d/100
    if sumf(i) == 1215:
        print(i, sumf(i))

  Posted by Larry on 2023-09-25 08:57:50
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 (3)
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