For a positive integer n, let Pn denote the product of the digits of n, and
Sn denote the sum of the digits of n. The number of integers between 10 and
1000 for which Pn + Sn = n is
Still Need Help?
Join the QuestionCove community and study together with friends!
idk i have just copy pasted that from ur reply abvoe
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
ik xD
i thought u might have sme idea
ganeshie8 (ganeshie8):
this looks more like a program problem as perl said
ganeshie8 (ganeshie8):
@dan815
ganeshie8 (ganeshie8):
notice that m is fixed here : m=2
ganeshie8 (ganeshie8):
they just want the solutions for 3 digit numbers
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
abc + (a+b+c) = 100a + 10b + c
ganeshie8 (ganeshie8):
thats a number theory problem
OpenStudy (perl):
should we include 1000 as well, we can check that one manually
OpenStudy (perl):
its false for 1000
OpenStudy (ikram002p):
ok here is my algorithm
1- set numbers from 10 to 100 in array as n[990]
2- send n[i] to Pn and Sn function
3- if statement to check
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (anonymous):
So much smart people. XD
ganeshie8 (ganeshie8):
abc + (a+b+c) = 100a + 10b + c
99a + 9b = abc
11a + b = abc/9
this is just a diophantine equation in "two" variables
solve the equation for `11a+b = 1` and extrapolate the results
OpenStudy (ikram002p):
oh lol
abc+a+b+c =100 a +10 b +c
OpenStudy (ikram002p):
ok lets do it :)
ganeshie8 (ganeshie8):
11a + b = 1
by inspection :
a = 1
b = -10
is one solution, so all other solutions can be given by : `a = 1+t`, `b=-10-11t`
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
next, we can find the values of c, such that `abc/9` is an integer
ganeshie8 (ganeshie8):
still wid me ikram
OpenStudy (perl):
why did you set it equal to 1
11a + b = 1
OpenStudy (ikram002p):
yepp
ganeshie8 (ganeshie8):
that allows us to multiply any number both sides and solve
for exampile, we can multiply abc/9 both sides here
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
if x,y are solutions of 11a + b = 1
then
x*abc/9 , y*abc/9 will be solutions of 11m + n = abc/9
yeah this is just not good enough
OpenStudy (ikram002p):
but still give an idea like conditions :O
ganeshie8 (ganeshie8):
because we want to solve 11a+b = abc/9
and not 11m+n = abc/9
OpenStudy (ikram002p):
i got ur point hmm
ganeshie8 (ganeshie8):
anyways atleas this much is clear :
9 | abc
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
remember the divisibility rule for 9 ?
OpenStudy (ikram002p):
so one of them must be 9 , since they are unit digits
ganeshie8 (ganeshie8):
oh right right !
ganeshie8 (ganeshie8):
one of them has to be 9
OpenStudy (perl):
if the sum of digits is divisible by 9
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
wait , a=9 or b=9 or c=9
or a=3 and b=3 something like this
ganeshie8 (ganeshie8):
its a*b*c
not abc, my bad im fully on offtrack on this problem
ganeshie8 (ganeshie8):
yup!
ganeshie8 (ganeshie8):
9 | a*b*c
ganeshie8 (ganeshie8):
thats just an observation, wont help us solve the problem
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
here is the answer if it helps you revere enginner
```
19
29
39
49
59
69
79
89
99
```
OpenStudy (ikram002p):
how did u get it ?
ganeshie8 (ganeshie8):
program
OpenStudy (ikram002p):
xD mine dint work ;_;
ganeshie8 (ganeshie8):
here is mine
```
foreach my $n (11 .. 999) {
my @digits = split //, $n;
my $sum = eval join '+', @digits;
my $prod = eval join '*', @digits;
print "$n\n" if ($sum+$prod == $n);
}
```
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
but this problem should be solved using number theory, the solutios are only few and they look pretty patterny
OpenStudy (ikram002p):
nvm xD
im not good in programming
OpenStudy (ikram002p):
yeah :)
OpenStudy (ikram002p):
so basically , 9|abc
ganeshie8 (ganeshie8):
9|a*b*c
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
yeah i now , if im gonna refer to n i would use 100a+10b+c
mathematician xD
ganeshie8 (ganeshie8):
okie
ganeshie8 (ganeshie8):
from the output, a = 0
any idea why it has to be so ?
OpenStudy (ikram002p):
so let
ok i might have an idea
OpenStudy (ikram002p):
9*9*9=729
9+9+9=27
so 729+27=756
so a cant be 9 :)
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
a=0 gives u 2 digit numbers, so we should consider 2 digit numbers and 3 digit numbers separately hmm
OpenStudy (ikram002p):
hmm
100a+10b+c = abc + a+b+c
so any digit we would take for a
100a+10b+c > abc + a+b+c
OpenStudy (ikram002p):
:D
thus we consider a=0
OpenStudy (ikram002p):
10b+c=bc+b+c
ganeshie8 (ganeshie8):
ohk keep going
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
9b=bc Xd
c=9
ganeshie8 (ganeshie8):
wow! that was easy
OpenStudy (ikram002p):
so all
19
29
39
49
59
69
79
89
99
ganeshie8 (ganeshie8):
nice :)
OpenStudy (ikram002p):
yeah i guess the trick in making a=0
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
im thinking about this :
100a+10b+c = abc + a+b+c
so any digit we would take for a
100a+10b+c > abc + a+b+c
is there a proof for this
OpenStudy (ikram002p):
lol i wont note that without seeing output xD
OpenStudy (ikram002p):
yeah let proof it
OpenStudy (ikram002p):
99a+9b>ab
ganeshie8 (ganeshie8):
claim : the value of a positive integer is always greater than the product of its digits
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
highest value that ab can take is 9*9 < 100
ganeshie8 (ganeshie8):
however the value of n is 10b + c only
OpenStudy (ikram002p):
:D
ganeshie8 (ganeshie8):
no its not clear to me yet
ganeshie8 (ganeshie8):
we want to prove
100a + 10b + c > a*b*c
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
oh lol
ok
100a+10b+c <abc+a+c+b
99a+9b<abc
now highest value that abc could take is 9*9*9 right ?
ganeshie8 (ganeshie8):
yes
OpenStudy (ikram002p):
so in other way we wanna prove this
99a+b > 9*9*9
99*9+9 > 9*9*9 true
OpenStudy (ikram002p):
wait hmm
ganeshie8 (ganeshie8):
100a+10b+c = 10(10a + b) + c > b(ca + b) = abc + b^2 > abc
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
xD
ganeshie8 (ganeshie8):
got it :) that was a very useful trick to stop after 2 digit numbers
OpenStudy (ikram002p):
wait what u did :O
ganeshie8 (ganeshie8):
100a+10b+c = 10(10a + b) + c
ganeshie8 (ganeshie8):
fine so far ?
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
OpenStudy (ikram002p):
yeah keep going
ganeshie8 (ganeshie8):
10 > b and 10 > c so :
100a+10b+c = 10(10a + b) + c
> b(ca + b) + c
ganeshie8 (ganeshie8):
fine ?
OpenStudy (ikram002p):
neat xD
yeah fine
ganeshie8 (ganeshie8):
i have replaced 10's with b and c and put the inequality
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
ganeshie8 (ganeshie8):
100a+10b+c = 10(10a + b) + c
> b(ca + b) + c
= abc + b^2 + c
> abc
OpenStudy (ikram002p):
nishe xD
OpenStudy (ikram002p):
hehe i tried to show it with maximum bhaha by taking 9 as highest blah
but this is more neat