Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

function module

Former Member
0 Kudos

for 3x + 4y + 2z LE 25 i want all possible values can any body suggest me.pls?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello

Try this code:


data: x type i,
      y type i,
      z type i,
      sum type i.
data: begin of itab occurs 0,
      x type i,
      y type i,
      z type i,
end of itab.
x = y = z = 0.
do 6 times.
  x = x + 1.
  do 5 times.
    y = y + 1.
    do 9 times.
      z = z + 1.
      sum = x * 3 + y * 4 + z * 2.
      if sum <= 25.
        itab-x = x.
        itab-y = y.
        itab-z = z.
        append itab.
      endif.
    enddo.
    z = 0.
  enddo.
  y = 0.
enddo.

In result table ITAB will be all possible values (natural numbers, without zeros).

If you need with zeros - modify this code itself

3 REPLIES 3

Former Member
0 Kudos

In a loop increment the value of x, y , and z and each time check LE 25 , If so append the values of x ,y,z into an internal table,

What is your actual requirement? ant value cab be assigned to x , y , z.

Regards,

Midhun Abraham

Edited by: Midhun Abraham on Oct 3, 2008 1:34 PM

Edited by: Midhun Abraham on Oct 3, 2008 1:35 PM

Former Member
0 Kudos

Hello

Try this code:


data: x type i,
      y type i,
      z type i,
      sum type i.
data: begin of itab occurs 0,
      x type i,
      y type i,
      z type i,
end of itab.
x = y = z = 0.
do 6 times.
  x = x + 1.
  do 5 times.
    y = y + 1.
    do 9 times.
      z = z + 1.
      sum = x * 3 + y * 4 + z * 2.
      if sum <= 25.
        itab-x = x.
        itab-y = y.
        itab-z = z.
        append itab.
      endif.
    enddo.
    z = 0.
  enddo.
  y = 0.
enddo.

In result table ITAB will be all possible values (natural numbers, without zeros).

If you need with zeros - modify this code itself

0 Kudos

thank u for ur reply i will go through it.