 # Q&A – Coding Challenge – Numbers dividable by 35

Recently we’ve received such email question from our ABAP Academy email subscriber:

So here is the answer I recorded for him and source code right below the video:

And here is the whole source code of the implemented solution:

``````*&---------------------------------------------------------------------*
*& Report  ZLR_LIB_HPL_CH_MOD_35
*&
*&---------------------------------------------------------------------*
*& Description:
*&   Use parameters, use loops to create a new report program .
*&      Use if, while statement.
*&      Use parameters.
*&      Input a number 200
*&
*&   After execution, display the result of numbers which can be divided
*&   by 35 and modulus is 0, which are lower than 200.
*&
*&---------------------------------------------------------------------*
*& Change log:
*& Date       Author      Action
*&
*&---------------------------------------------------------------------*

REPORT zlr_lib_hpl_ch_mod_35.

*-----------------------------------*
* DECLARATIONS

DATA:
gv_result            TYPE p DECIMALS 2,
gv_calculated_number TYPE i.

*-----------------------------------*
* SELECTION-SCREEN

" Integer for result which can be divided by 'Dividable By'
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE TEXT-b01.
PARAMETERS:
p_input TYPE i,  " Input Number
p_div   TYPE i DEFAULT 35. " Dividable By

SELECTION-SCREEN END OF BLOCK b01.

*-----------------------------------*
* MAIN LOGIC

" Initialize calculated number
gv_calculated_number = p_input.

" For each and every number we need to check if it's dividable by P_DIV DO p_input TIMES.

" Get the result of modulo division
gv_result = gv_calculated_number MOD p_div.

IF gv_result = 0.

WRITE: / gv_calculated_number.

ENDIF.

gv_calculated_number = gv_calculated_number - 1.

ENDDO.``````