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

Home > Algorithms
Divisible by 13 (Posted on 2022-04-15) Difficulty: 3 of 5
Devise an algorithm that determines whether a given positive integer N is divisible by 13, and if NOT, to find the remainder.
N can contain up to 20,220 digits.

Note: Simply dividing by 13 or, performing long division by 13 is NOT permissible.

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.)
re(2): No Subject | Comment 6 of 11 |
(In reply to re: No Subject by Charlie)

I originally had:

if temp%13 == 0:
        return True
    else:
        return False
But added the other since it asks for the remainder.
Or you could end with 
    if temp%13 == 0:
        return temp%13
    else:
        return temp%13
Which gives the remainder only.


But I think the main point is, is it ok to divide a small number by 13?  I would assume that the intent was to not divide a huge number by 13, but OK to divide a small number by 13.  If this is not the case then repeated subtraction of 13 seemingly would be OK stopping when you get to a number from 0 to 13.  (or adding 13 if you start out with a negative small number).

  Posted by Larry on 2022-04-15 14:07:28
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 (16)
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