Python 2, 41 bytes
n=k=j=input()
while~k<0:j-=1;k-=j*(n%j<1)
Output is via exit code, so 0 is success and 1 is fail.
Try it online! (check the Debug drawer)
Dennis
- 211.7k
- 41
- 380
- 830
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.
Visit Stack Exchangen=k=j=input()
while~k<0:j-=1;k-=j*(n%j<1)
Output is via exit code, so 0 is success and 1 is fail.
Try it online! (check the Debug drawer)