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: 

logical questions

Former Member
0 Kudos

1.write a program to generate prime numbers from 0 to 100.

2.write the code for the following output

3*1=0003

3*2=0006

3*3=0009

and so on

7 REPLIES 7

Former Member
0 Kudos

REPORT ztest1 .

PARAMETERS: p_from TYPE i,

p_to TYPE i.

DATA: v_from TYPE i,

v_to TYPE i,

v_remainder TYPE i,

v_is_prime TYPE c,

v_divisor TYPE i.

START-OF-SELECTION.

v_from = p_from.

v_to = p_to.

DO.

IF v_from = v_to.

EXIT.

ENDIF.

CLEAR v_is_prime.

DO v_from TIMES.

v_divisor = sy-index.

v_remainder = v_from MOD v_divisor.

IF v_divisor <> 1 AND

v_divisor <> v_from AND

v_remainder = 0.

*-- not a prime

v_is_prime = 'N'.

EXIT.

ENDIF.

ENDDO.

IF v_is_prime IS INITIAL.

*-- the number is prime

WRITE:/ v_from, 'is a prime number'.

ENDIF.

v_from = v_from + 1.

ENDDO.

0 Kudos

thanks

Former Member
0 Kudos

Sagarika,

1. Take a look at this thread

2.

data : n1 type i value 3,

n2 type i value 1,

result(4) type n.

do.

result = n1 * n2

write 😕 n1, '*', n2, '=', result.

n2 = n2 + 1.

if sy-index = 10.

exit.

endif.

enddo.

Regards,

Ravi

Note :Please mark the helpful answers

0 Kudos

thanks ravi

Former Member
0 Kudos

hi sagarika,

1) check these links.

2)parameters: x type i.

do 10 times.

b = x * sy-index.

write:/ 'result', b.

enddo.

hope this helps,

priya.

0 Kudos

thanks priya i will check it out

0 Kudos

hi,

look here:

Andreas