Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on *:TEXT:!prime *:#: {
- if ($2 isnum) {
- if ($2 < 100000) && ($2 > 0) {
- if ($2 != $round($2,0)) {
- msg $chan no decimals bro.
- }
- else {
- msg $chan $prime($2)
- }
- }
- elseif ($2 < 1) {
- msg $chan don't be silly bro. no negatives...or zeroes.
- }
- else {
- msg $chan that number is too huge bro.
- }
- }
- else {
- msg $chan must be a number.
- }
- }
- alias prime {
- var %x $1
- var %y 1
- var %factors 0
- set %vFct
- while (%y <= %x) {
- var %fct %x % %y
- if (%fct == 0) {
- inc %factors
- set %vFct %vFct %y
- }
- inc %y
- }
- if (%factors == 2) {
- var %msg %x is a prime
- }
- else {
- var %msg %x is not a prime
- }
- return %msg - Factors: %vFct
- unset %vFct
- }
Add Comment
Please, Sign In to add comment