i have 4 numbers ex(45,36,31,14)
and i want to put all the posiblities that is lower or equal ex(100)
so if the sum of it is lower or equal the program writes the qualification he solved
for example we start with number 45
100>45 so print "45"
45+45=90
100>90 so print "45 - 45"
45+45+45=135
100<135 so it goes to the next step
45+36=81
100>81 so print "45 - 36"
45+36+36=117
100<117 so it goes to the next step
45+36+31=112
100<112 so it goes to the next step
45+36+31+14=126
100<126 so it goes to the next step
45+36+14=95
100>95 so print " 45 - 36 14"
and i don't know what is the way to make a loop like this
and the result sould be like this
and i tried and i've succeded to make all posiblities for no. 45Code:45 45 - 45 45 - 36 45 - 36 - 14 45 - 31 45 - 31 - 14 45 - 14 45 - 14 - 14 45 - 14 - 14 -14 36 36 - 36 36 - 36 - 14 36 - 36 - 14 - 14 36 - 31 36 - 31 - 31 36 - 31 - 14 36 - 31 - 14 - 14 36 - 14 36 - 14 - 14 36 - 14 - 14 - 14 36 - 14 - 14 - 14 - 14 31 31 - 31 31 - 31 - 31 31 - 31 - 14 31 - 31 - 14 - 14 31 - 14 31 - 14 - 14 31 - 14 - 14 - 14 31 - 14 - 14 - 14 - 14 14 14 - 14 14 - 14 - 14 14 - 14 - 14 - 14 14 - 14 - 14 - 14 - 14 14 - 14 - 14 - 14 - 14 - 14 14 - 14 - 14 - 14 - 14 - 14 - 14
and all fo no.36 except
36 - 36 - 14
36 - 36 - 14 - 14
and it doesn't matter how the code is long or complecated all i want is to get the final result
and if there is any point u understand tell me and i'll explain what u want
thank u and good bye




Reply With Quote