AMCAT Automata Fix Sample Question-3

Program 3

Multiple of 3 and 5

 You are required to write the logical part for the function that takes an integer ‘n’ as input and returns a string array ‘answer’ of length ‘n’. Each element ‘answer[i]’ in the array is determined based on the following rules:

If ‘i’ is divisible by both 3 and 5, ‘answer[i]’ should be set to “PrepInsta”.

If ‘i’ is divisible by 3 but not by 5, ‘answer[i]’ should be set to “Prep”.

If ‘i’ is divisible by 5 but not by 3, ‘answer[i]’ should be set to “Insta”.

If none of the above conditions are true, ‘answer[i]’ should be set to the string representation of ‘i’.

2 comments on “AMCAT Automata Fix Sample Question-3”