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.)

See The Solution Submitted by Chesca Ciprian    
Rating: 3.0000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution (Rough Program) Comment 3 of 3 |
My Solution is a recursive function with number as arguement

Recursive function(num)
i=0,num,sum=0;
Loop2:
sum=sum+(-1)^i * num%10;
num=num/10;
i++;
check if num =0, else repeat loop2
if num=0, exit from loop;
check if sum <11, else repeat the Recursive function(sum)
if sum < 11 & sum =0 , print "Yes -- Divisible by 11"
if -11 < sum <11 & sum!=0, print "No -- Not Divisible by 11"


Edited on January 3, 2008, 1:39 am
  Posted by Praneeth on 2008-01-03 01:02:06

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
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