Programming contests

Magas szintű programozási nyelvek 1, egyéni verseny, 2016. április 10.

April 10, 2016 10:00 AM – April 10, 2016 3:00 PM

f91

McCarthy is a famous theoretician of computer science. In his work, he defined a recursive function, called f91, that takes as input a positive integer N and returns a positive integer defined as follows:

  • if N ≤ 100, then f91(N) = f91(f91(N + 11));
  • if N ≥ 101, then f91(N) = N – 10.

Write a program that computes McCarthy's f91.

Input Specification

The input will consist of a series of positive integers, each integer is at most 1 000 000. There will be at most 250 000 test cases. Each number is on a line on its own. The end of the input is reached when the number 0 is met. The number 0 should not be considered as part of the test set.

Output Specification

The program should output each result on a line by its own, following the format given in the sample output.

Sample Input

  1. 500
  2. 91
  3. 0
download as text file

Output for Sample Input

  1. f91(500) = 490
  2. f91(91) = 91
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019