So, based on what you're describing here, you want a while loop, since you want to keep doing something until a given condition becomes true.
lastOutput = 0; # an arbitrary starting value: the last output value
# needs to be shared between loop cycles, so its
# scope must be outside the while loop
startingValue = # whatever you start at for input
finished = False # flag for tracking whether desired value has been reached
while (!finished):
# body of loop:
# here, you need to take lastOutput, run it through the
# function again, and check if the new output value is the
# same as the input that created it. If so, you are done,
# so set the flag to True, and note that the correct value is now stored in lastOutput
# If not, set the new output as lastOutput, and go again!
# ...and now finish up with whatever you want to do now that you've
# found the value (print it, etc.)!
As far as the logic for checking whether the values are the same, you will need to have some sort of threshold value for precision purposes (otherwise it'll run forever!), and I would recommend writing that check in its own method for modularity's sake.
Hope this helps, and just let me know if you need me to post more actual code (I tried not to give away too much actual code).
while
loop. – shashwat Jun 14 '13 at 17:51