Guest User

Untitled

a guest
Dec 8th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 0.77 KB | None | 0 0
  1. on *:TEXT:!prime *:#: {
  2.   if ($2 isnum) {
  3.     if ($2 < 100000) && ($2 > 0) {
  4.       if ($2 != $round($2,0)) {
  5.         msg $chan no decimals bro.
  6.       }
  7.       else {
  8.         msg $chan $prime($2)
  9.       }
  10.     }
  11.     elseif ($2 < 1) {
  12.       msg $chan don't be silly bro. no negatives...or zeroes.
  13.     }
  14.     else {
  15.       msg $chan that number is too huge bro.
  16.     }
  17.   }
  18.   else {
  19.     msg $chan must be a number.
  20.   }
  21. }
  22. alias prime {
  23.   var %x $1
  24.   var %y 1
  25.   var %factors 0
  26.   set %vFct
  27.   while (%y <= %x) {
  28.     var %fct %x % %y
  29.     if (%fct == 0) {
  30.       inc %factors
  31.       set %vFct %vFct %y
  32.     }
  33.     inc %y
  34.   }
  35.   if (%factors == 2) {
  36.     var %msg %x is a prime
  37.   }
  38.   else {
  39.     var %msg %x is not a prime
  40.   }
  41.   return %msg - Factors: %vFct
  42.   unset %vFct
  43. }
Add Comment
Please, Sign In to add comment