This task is recommended to be performed at home. To perform it, you need to find the appropriate formulas on the Internet.
R
P%
M
P
if
for
while
until
1000 ms 256 Mb Rules for program design and list of errors in automatic problem checking