Advertisement
ipsBruno

(Javascript) Validar número triangular

Mar 13th, 2012
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  *  Copyright (c) 2012 [iPs]TeaM
  3.  *  Bruno da Silva (brunoemail@r7.com)
  4.  *  Função para saber se o número faz parte da sequencia triangular ou não
  5.  
  6.  * www.brunodasilva.com
  7.  * www.ips-team.forumeiros.com
  8. */
  9.  
  10. function isTriangular(n)
  11. {
  12.     n42 = Math.round(Math.sqrt(n * 2));
  13.     return (n42 * (n42 + 1)) == n * 2;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement