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

Home > Numbers
Divisible and not Divisible (Posted on 2023-06-19) Difficulty: 3 of 5
Determine the minimum value of a positive integer N such that N divides 2N-2, but N does NOT divide 3N - 3.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 1 of 3
Hopefully, the algorithm I used does not fall victim of overflow or rounding errors.  Using repeated subtractions (and multiplications) until the number is small keeps the large number calculations as integer math instead of float.

The first several solutions:
341
645
1387
1905
2047
3277
4033
4369
4371
4681
5461

---
def divides(n,d):
    """ bool   Does d evenly divide N?  """
    import math
    result = n
    while result > d:
        result =  result - d * 10**int(math.log(result,10) - math.log(d,10))
    return result%d == 0

big = 5500
for n in range(1,big):
    if divides(2**n-2,n) and not divides(3**n-3,n):
        print(n)

  Posted by Larry on 2023-06-19 13:53:18
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