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

Home > Algorithms
Divisible by 11 (Posted on 2008-01-02) Difficulty: 3 of 5
Give an algorithm that determines whether a given number is divisible by 11 or not. The number could have up to one million digits.

(Note that simply dividing by 11, or doing long division by 11 is not allowed as a solution.)

  Submitted by Chesca Ciprian    
Rating: 3.0000 (2 votes)
Solution: (Hide)
A number is divisible by 11 if the diference between sum of the digits from odd position and the digits from even position are divisible by 11. n=123456789 s1=1+3+5+7+9=25 s2=2+4+6+8=20 s1-s2=5 so the number is not divisible by 11. n=1122334455 s1=1+2+3+4+5 s1=1+2+3+4+5 s1-s2=0 so the number is divisible by 11. The algorithm read from a file the digits of a "long number" char after char, calculate the sums and determine if the number is divisible by 11.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
SolutionSolution (Rough Program)Praneeth2008-01-03 01:02:06
Solutionas a computer programCharlie2008-01-02 18:04:12
SolutionSolution without proofKurious2008-01-02 17:46:02
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 (6)
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