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

Home > Numbers
A counting task (Posted on 2018-08-23) Difficulty: 3 of 5
a. How many 5-digit numbers exist where one of its digits equals the sum of all other digits?
b. What is the sum of all those numbers?

No leading zeroes.

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
counting | Comment 3 of 7 |
In this case it is far easier to program than do the combinatorics.

I get: cnt tot        2658 109249191

program di

        implicit none

        integer i1,i2,i3,i4,i5,i6,icnt

        integer*16 itot

        icnt=0

        itot=0

           do i1=1,9

                do i2=0,9

                   do i3=0,9

                        do i4=0,9

                           do i5=0,9

        if(

        1 i5+i2+i3+i4.eq.i1.or.

        2 i1+i5+i3+i4.eq.i2.or.

        3 i1+i2+i5+i4.eq.i3.or.

        4 i1+i2+i3+i5.eq.i4.or.

        5 i1+i2+i3+i4.eq.i5)then

        print 1,i1,i2,i3,i4,i5

1       format(5i1)

        icnt=icnt+1

        itot=itot+ i1*10000+i2*1000+i3*100+i4*10+i5

        endif

                           enddo

                        enddo

                   enddo

                enddo

           enddo

        print*,' cnt tot',icnt,itot

        end

this has been edited to correct a programming error pointed out later by Charlie. 

Edited on September 16, 2018, 12:12 am

Edited on September 16, 2018, 12:13 am
  Posted by Steven Lord on 2018-08-23 10:16:58

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