A certain positive integer N is twice the product of its digits.
Find N.
Note - one need only search numbers up to n digits, where
2 x 9^n > 10^n
So n is less than or equal to 6. After that the equality is impossible since at n=7, 10^ 7 > 2 * 9*9*9*9*9*9*9
program pu
implicit none
integer i,j,dum,prod,top,dig
do i = 1, 10**7
prod=1
dum=i
top=log10(1.*i)
do j=top,0,-1
dig=dum*10.**(-j)
prod=prod*dig
dum=dum-dig*10**j
enddo
if(2*prod.eq.i)print*,i
enddo
end
rabbit-3:~ lord$ pu
36
rabbit-3:~ lord$
Edited on October 29, 2019, 11:52 am