ABCLOG - Time to get a job

ABC Pvt. Ltd., needs to recruit some candidates and they want the test to be somewhat new, rather than the conventional way of asking questions in all areas. They have a logic, which converts one integer to another. Your task is to find the logic behind it and then solve the questions for certain inputs.

The question given by them is as follows:

The following are the output provided for the inputs given to one of our newly bought machines. You need to find the output that will be generated for the given inputs. Some sample input and output are:

   4 -> 1, 23 -> 29, 7 -> 7  16 -> 1

 

Your task is to find the machine's output for some inputs

Input

Input contains several integers, each in a single line.

Input ends with a -1

All inputs <= 10^16

Output

Output one integer for every input, as said above.

Example

Input:
4
7
23
-1

 Output: 1
7
29

Added by:Aswin Murugesh
Date:2013-12-21
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem

hide comments
2017-04-06 17:59:36
careful with integer
2016-09-08 06:47:16
what is the output if we set the input is negative? ex : -2
2015-11-10 08:02:23 Prakhar Dev Gupta
Nice question!

Last edit: 2015-11-10 13:23:15
2015-09-18 19:30:13 Nguyễn Duy Anh
machineeeeeeee
2015-02-01 16:21:56 deepak garg
@Aswin please update the test cases for input 0
2014-10-16 12:48:06 shravan
12642491 can you please take a look, shouldn't cause any problem IMO
2014-10-05 21:20:20 varun
Not sure why I am getting WA, can someone check.
id = 12551028
2014-07-18 19:49:23 Baojun Wang


Last edit: 2014-07-18 21:59:02
2014-01-11 19:43:49 Vipul Pandey
easy!
2014-01-08 21:01:57 Mitch Schwartz
Moved to riddle.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.