Skip to content

Instantly share code, notes, and snippets.

@butchi
Created September 11, 2014 16:17
Show Gist options
  • Save butchi/89aee403e98a3b7e9cda to your computer and use it in GitHub Desktop.
Save butchi/89aee403e98a3b7e9cda to your computer and use it in GitHub Desktop.
yukicoder no.25
(* http://ch.nicovideo.jp/programing/blomaga/ar620922 *)
lastDigit[n_, m_] := With[
{rd = RealDigits[n/m, 10]},
Piecewise[{
{-1, Depth[First[rd]] > 2 || Head[Last[rd]] === List},
{Last[Cases[First[rd], Except[_?(#1 === 0 & )]]], True}}
]
]
lastDigit[95367431640626, 95367431640625]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment