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
2014-01-08 15:12:19 Lakshay Singhal
AC in first attempt... my 150th...nyc and simple que.
d logic lies in basics....

Last edit: 2014-01-08 15:12:47
2014-01-03 08:32:53 SanchitK
AC at first attempt! :D
2014-01-03 05:12:08 ritz
wow.. nice problem... :) (Y)
2014-01-01 20:07:30 pushkar nagar
acc with fast i/o.....
2014-01-01 17:15:47 saurabh jain
please admin check this my code 10780992 got compilation error with with c++ 4.3.2 but successfully aced with 4.0.0.-8 why
??
2013-12-31 17:45:39 ..........
After 7 WAs finally accepted!50th prob......
2013-12-31 01:04:06 Martijn Muijsers
Easy logic, but I don't like this type of description I guess.

Last edit: 2013-12-31 01:18:20
2013-12-30 19:52:13 pika_pika
big hint! thanks @pǝddıןɟ
2013-12-30 16:20:51 [Lakshman]
@ Saransh Sharma all numbers are positive.
2013-12-30 15:47:09 Saransh Sharma
does input contains negative integers also?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.