+ 10
❗Challenge🤓 : Solve the Ramanujan Problem🎓
🌸You have to take a positive integer number as an input and find out number of ways, sum of it can be represented using positive integers. 🌸As example If input is 3 : way 1 > 1+1+1 way 2 > 2+1 way 3 > 1+2 🌸If input is 4 : way 1 > 1+1+1+1 way 2 > 1+1+2 way 3 > 1+2+1 way 4 > 1+3 way 5 > 2+1+1 way 6 > 2+2 way 7 > 3+1 🌸Great Ramanujan made equation for this problem and in that time no one was able to prove the equation. 🌸I bet they never knew any coding. But here you are.... Start Coding...!!🤓🤓
32 Réponses
+ 25
//haha ... this quesn comed in mind while doing something else so i thought to share what i thought , have a look at this
(a+1)+(b+1)+ .... +(r+1) = n-r //a,b,c...r>=0
//(n-1)C(r-1) solutions ... 1st eqn
nC0 +nC1 + nC2 + .... nCn = 2^n
//take it as eqn... 2
for n to be expressed as sum of n,n-1,n-2 ... 2 terms
//by using 1st eqn
(n-1)C(1)+(n-1)C(2)+ ... (n-1)C (n-2)+(n-1)C(n-1)
//using 2nd
= 2^(n-1) - (n-1)C0
=2^(n-1) - 1
+ 22
//mine try ☺👍
https://code.sololearn.com/cr1bgunGIf6V/?ref=app
+ 19
@zeel Patel
//how u made that formula ?????
//don't say by noticing the output for different inputs
+ 17
+ 10
my try
https://code.sololearn.com/cLFU7vrOgsiV/?ref=app
My thoughts with example 4:
i have 4 stones lying in a row
Between the stones i can put seperator.
, max 3.
i can choose 1,2 and 3 seperator at places 1 2 and three.
eg
stone x stone stone x stone -> 1 2 1
3 opps for one stone 3 opps for two stones one opp for three stones
btw: with 4 is allowed... zero stones one opp
1331
which is the third row of pascal triangle
Thanks for that challenge!
+ 6
these types of problem can be proved by PMI
//I personally hate this(not formula but Pmi)
//I don't consider it as mathematics
//btw ramanujan is my favorite and is the best!!!!
+ 6
@zeel in mathematic the biggest fool can ask questiones, that cant be answered by the most genious mathematican.
quote free remembered
+ 6
The easiest answer for only counting the possibillities for a given number n:
add all items of the (n-1)th row of Pascal Triangle.
Somehow finally everything in math is sin, cos or Pascal :-))
+ 5
At last Sayan bro wanna say that if we know question, if we know answer too, it is easier to solve the question..😁😉😉😀😀👍
+ 5
yes it's just 2^n-1
The 1 come from the number itself, an invalid way.
+ 3
works for large n. here with 20. https://code.sololearn.com/cN0n8eiMAkK9/?ref=app
+ 3
Real magic is here..😀
https://code.sololearn.com/caUvHorNYG3X/?ref=app
+ 3
But I believe that there must be some well-established mathematical long enough to satisfy us proof for this question hidden somewhere in Google, wanna get the gold..? dig then..😉😉😊
+ 2
My try is here, now your turn guys..!!
https://code.sololearn.com/cMeA5EI16ROL/?ref=app
+ 2
@Gaurav Agrawal Yes, Sayan is right, but I didn't knew formula when I posted this question. After people answered question, I found it interesting and googled about it, then I came to know it was such simple formula, it really surprised me that such complicated thing can have such simple formula..!... That's why Maths is Magic..😀😀
+ 2
@Gaurav Agrawal Same has happened to me bro. I will not say wasted but struggled my whole morning finding the relationship between input and output but it is not the failure, when we try to solve some riddle, our mind gets exercise, so in one or another way time can be called utilized.
+ 2
ok...let me give u my theory...
@ Gaurav
see...suppose the num is 5...
the ans will be the total number pf numbers from (5+1) to 11111 that have digits summing up to 5...
14
23
32
41
113
122
131
212
221
311
1112
1121
1211
2111
11111......total 15(all sum up to 5)
easy to find with a code ...
ans=0
for i in range (5+1) to 11111
if sumdigit(i)==5 : ans+=1
+ 2
sayan is back but with english multiliners
+ 2
@saurabh why PMI is bad
+ 1
the proof is easy
nothing but a trial and deduction...
1---0
2---1
3---3
4---7
5---15
.........
n---2^(n-1)-1..
@Gaurav...1 shdn't give 1...
as in any other number n...we r nt considering..
n=n...
else 4 shd give 8...
but thats nt the case...
as 4---7 so 1 shd give 0