Program For Printing Prime Number

*&---------------------------------------------------------------------*
*& Report  ZPRIME                                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
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.
ABAP Tips by : Shanmugam

Fast Links:
Other ABAP samples program

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.