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

Prime number Program in ABAP

Former Member
0 Likes
9,182

Hi,

Plz send the program for prime number.

Hi,

Plz send the program for prime number.

3 REPLIES 3
Read only

Former Member
0 Likes
3,265

Hi,

Following is the program for prime number

Report zprime.

parameters : num type i.

data : res type i.

res = num MOD 2.

if res = 0.

write : 'This is not a prime number'.

else.

write : num, 'is a prime number.'.

endif.

Read only

anversha_s
Active Contributor
0 Likes
3,265

hi Nagraju,

Check this out u will find a solution for your question

<b><i>Note : Please close ur factorial query. I already gave u the correct answer for that.</i></b>

Regards

anversah

Read only

Former Member
0 Likes
3,265

hi

good

go through this program

REPORT zprime .

DATA : t_no TYPE i,

res TYPE p,

pr_no TYPE p,

tag TYPE i.

SELECTION-SCREEN BEGIN OF BLOCK b1.

PARAMETERS : pr_num TYPE i.

SELECTION-SCREEN END OF BLOCK b1.

pr_no = 1.

WHILE pr_no LE pr_num.

t_no = 2.

tag = 0.

WHILE t_no < pr_no.

res = pr_no MOD t_no.

IF res = 0.

WRITE : / pr_no.

WRITE : 'is not PRIME Number ' COLOR 3 INTENSIFIED OFF.

tag = 1.

EXIT.

ENDIF.

t_no = t_no + 1.

ENDWHILE.

IF tag = 0.

WRITE : / pr_no.

WRITE : 'is PRIME Number ' COLOR 6 INTENSIFIED OFF.

ENDIF.

pr_no = pr_no + 1.

ENDWHILE.

thanks

mrutyun^