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

Home > Numbers
String of 8s and Divisibility (Posted on 2023-07-19) Difficulty: 3 of 5
N corresponds to a string of 8s given by 888888....8888, where N is divisible by 299.

Find the last four digits of the quotient when N is divided by 299.

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 3 of 3 |
The sequence of n 8s mod 299 has a period of 66.
So zero 8's is 0 mod 299, as is 66 8s, 132 8's etc.
The function below treats the dividend and quotient as lists of integers, then outputs the dividend and remainder.

('002972872538089929394277220364176885916016350798959494611668524712', 'with remainder', 0)
So the last 4 digits are 4712

This is also true for the multiples of 66:
132:
('002972872538089929394277220364176885916016350798959494611668524712
002972872538089929394277220364176885916016350798959494611668524712', 'with remainder', 0)

198:
('002972872538089929394277220364176885916016350798959494611668524712
002972872538089929394277220364176885916016350798959494611668524712
002972872538089929394277220364176885916016350798959494611668524712', 'with remainder', 0)

--------------------
def large_divide(divisor, dividend):
    if type(dividend) == str:
        dividend = [int(i) for i in dividend]
    elif type(dividend) == int:
        dividend = [int(i) for i in str(dividend)]
    quotient = []
    tempdividend = 0
    i=0
    for i,v in enumerate(dividend):
        tempdividend = tempdividend*10 + dividend[i]
        quotient.append(tempdividend // divisor)
        tempdividend = tempdividend % divisor
    return ''.join([str(j) for j in quotient]), 'with remainder', tempdividend

print(large_divide(299, '8'*66))
print(large_divide(299, '8'*132))
print(large_divide(299, '8'*198))


  Posted by Larry on 2023-07-19 16:39:07
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