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

Home > Numbers
98 Crossed Sum of Digits Puzzle (Posted on 2023-07-03) Difficulty: 3 of 5
Determine the minimum value of a positive integer N that satisfy the following conditions:
  1. N is a multiple of 101.
  2. N starts with and ends in 98.
  3. sod(N) = 94
*** sod(N) denotes the sum of the digits of N.
For example, sod(3456) = 3+4+5+6 = 18

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 computer solution | Comment 2 of 6 |
clearvars
n=[8 9 9 9 9 9 9 9 6 8 9];
pval=1;
for i=2:11
  pval(i)=mod(pval(i-1)*10,101);
end
dec=1;
for i=2:11
  dec(i)=dec(i-1)*10;
end

totVal=mod(sum(n.*pval),101);
sum(n.*dec)

found=false;
while ~found
  for i=4:9
     if n(i)<n(i-1)
       n(i)=n(i)+1; n(i-1)=n(i-1)-1;
       totVal=mod(totVal+pval(i)-pval(i-1),101);
       if totVal==0
         found=true;
         break
       end
     end
  end
end
disp(sum(n.*dec)) 

fails to find an 11-digit solution. (The procedure was terminated manually as only finding an answer would terminate it by itself, and found to have gotten to the highest value.)

clearvars,clc
n=[8 9 9 9 9 9 9 9 6 0 8 9];
pval=1;
for i=2:12
  pval(i)=mod(pval(i-1)*10,101);
end
dec=1;
for i=2:12
  dec(i)=dec(i-1)*10;
end

totVal=mod(sum(n.*pval),101);
sum(n.*dec)

found=false;
while ~found
  for i=4:10
     if n(i)<n(i-1)
       n(i)=n(i)+1; n(i-1)=n(i-1)-1;
       totVal=mod(totVal+pval(i)-pval(i-1),101);
       if totVal==0
         found=true;
         break
       end
     end
  end
end
disp(sum(n.*dec))

does find a 12-digit solution:

987777888898

The program stores the lowest number with the appropriate beginning, ending and sod. It's stored "backwards", units position first. The positions after the terminal 89 (backward remember) are examined until an decrease in the digit value is found compared to the previous. The previous is decremented and the current one incremented, maintaining the sod. The value of the whole n is adjusted using the modular values of those positions. Once a value mod 101 of zero is found the algorithm stops. 


  Posted by Charlie on 2023-07-03 13:59:43
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 (8)
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