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.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
f=lambda n,d,*rr=[0,0]:(0,0,0,*r[r[:1],*r3]+r).count(n)or f(10*n%d,d,*r,nr+[n])
Prints 1 for eventually periodic, 2 for purely periodic, and 34 for terminating.
Verify all test cases on repl.itrepl.it.
f=lambda n,d,*r:(0,0,0,*r[:1],*r).count(n)or f(10*n%d,d,*r,n)
Prints 1 for eventually periodic, 2 for purely periodic, and 3 for terminating.
Verify all test cases on repl.it.
f=lambda n,d,r=[0,0]:(r[:3]+r).count(n)or f(10*n%d,d,r+[n])
Prints 1 for eventually periodic, 2 for purely periodic, and 4 for terminating.
f=lambda n,d,*r:n in r and~(20,n==r[0]0,0,*r[:1],*r)[n>0]or.count(n)or f(10*n%d,d,*r,n)
Prints -31 for terminatingeventually periodic, -2 for purely periodic, and -13 for eventually peridicterminating.
f=lambda n,d,*r:n in r and~(2,n==r[0])[n>0]or f(10*n%d,d,*r,n)
Prints -3 for terminating, -2 for purely periodic, and -1 for eventually peridic.