Google Apac Test D Problem A

Apart from the formula , Can someone provide a pseudocode solution to Problem A
Thanks in advance :slight_smile: