Application Development and Automation 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: 
Read only

logical questions

Former Member
0 Likes
1,065

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

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
Read only

Former Member
0 Likes
981

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.

Read only

0 Likes
981

thanks

Read only

Former Member
0 Likes
981

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

Read only

0 Likes
981

thanks ravi

Read only

Former Member
0 Likes
981

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.

Read only

0 Likes
981

thanks priya i will check it out

Read only

0 Likes
981

hi,

look here:

Andreas