samba

Automorphic

Apr 1st, 2010
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. /* Guess automorphic number by matching the 1's place in integers... */
  2.  
  3. Number.prototype.isAutomorphic = function(){
  4.     var sq = (this * this).toString(), selfstr = this.toString();
  5.     return (sq.charAt(sq.length - 1) == selfstr.charAt(selfstr.length - 1));
  6. }
  7.  
  8. /* implementation */
  9. var t = 5;
  10. alert("t automorphic? " + t.isAutomorphic().toString());
Advertisement
Add Comment
Please, Sign In to add comment