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

Home > Numbers
Digital Sum 11 (Posted on 2008-12-08) Difficulty: 3 of 5
Two consecutive numbers both have a digital sum which is a multiple of 11. What is the smallest pair of numbers?

Note: the digital sum is the number equalling the sum of all the digits of the number. For example the digital sum of 123456 is 21.

See The Solution Submitted by Brian Smith    
Rating: 3.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution brute force solution | Comment 4 of 5 |
Perl solution:

my $prev_sum=2; # any non-zero value will do
my $sum;

for (29..1e7) { # smallest to relatively large
$sum=0;
map {$sum+=$_;} split("", $_); # calculate sum
unless ($sum % 11) { # if sum divisible by 11
unless ($prev_sum % 11) { # same for previous
die "$_ and $_ - 1\n" # end search
} else {
$prev_sum=$sum
}
} else {
$prev_sum=2; # not divisible by 11
}
}

  Posted by Moira on 2009-01-21 22:58:24
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 (14)
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