# TI-Basic (83/84 version), 40 bytes

    Input A:For(I,A,2,~1:A+(AfPart(I/2)-1)I(1>IfPart(A/I->A:End:A

[Information about TI-Basic][1]

  [1]: http://tibasicdev.wikidot.com/home