Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Optimization of innat3's C# (Visual C# Interactive Compiler), 100 bytes
f(n,i,t,r,m){for(t=0,m=n;r-2;t++)for(r=i=1,n+=n<m?t:-t;i<n;n%++i||r++);}
Try it online!
f(n,i,t,r,m){for(t=0,m=n;r!=2;t++-2;t++)for(r=i=1,n+=n<m?t:-t;i<n;n%++i?0:r++t;i<n;n%++i||r++);}
Try it online!Try it online!
f(n,i,t,r,m){for(t=0,m=n;r!=2;t++)for(r=i=1,n+=n<m?t:-t;i<n;n%++i?0:r++);}
This is an optimized version of "C# (Visual C# Interactive Compiler), 100 bytes"
f(n,i,t,r,m){for(t=0,m=n;r!=2;t++)for(r=i=1,n+=n<m?t:-t;i<n;)n%++i>0t;i<n;n%++i?0:r++;r++);}
f(n,i,t,r,m){for(t=0,m=n;r!=2;t++)for(r=i=1,n+=n<m?t:-t;i<n;)n%++i>0?0:r++;}