How would you solve this 'interview' question in D?

John Colvin john.loughran.colvin at gmail.com
Thu Jun 27 06:07:06 PDT 2013


On Wednesday, 26 June 2013 at 23:14:09 UTC, H. S. Teoh wrote:
> I think the 4-cycle algorithm is
> probably still the best one I've seen.

All (correct) mathematically based answers are 4-cycle.

begin very sloppy proof with mixed up notation:

Let f^2(x) = -x
f^4(x) = f^2(f^2(x))
        = f^2(-x)
        = -(-x)
        = x

Therefore:

f^4 = 1
f^{4n} = 1^n = 1,     n in N
<==> f^{4n}(x) = x
□


More information about the Digitalmars-d-learn mailing list