
-----------------------------------
Nick
Tue Sep 25, 2007 4:40 pm

prime number detector
-----------------------------------
I was bored so i made this


var num : int
var sent : int := 0

proc prime (value : int)
    for i : 2 .. value
        for ii : 2 .. value
            if i * ii = value then
                put i, '*', ii
                sent += 1
            end if
        end for
    end for
    if sent = 0 then
        put "Prime number"
    end if
    sent:=0
end prime

loop
    put "enter a number: " ..
    get num
    prime (num)
    locate (1, 1)
    Input.Pause
    cls
end loop



it tells you if the inputted number is a prime number and if not then it outputs all the possiblities to get the number via multiplacation

-----------------------------------
Tony
Tue Sep 25, 2007 6:48 pm

Re: prime number detector
-----------------------------------
all the possiblities to get the number via multiplacation
Those are called factors ;)

-----------------------------------
Nick
Tue Sep 25, 2007 6:50 pm

Re: prime number detector
-----------------------------------
lmao whatever it works and i forgot the name :oops: anyways thanks for the reminder

pps i made this program in like 5 mins tops so if theres any errors... well it was bound to happen

-----------------------------------
Cervantes
Tue Sep 25, 2007 7:17 pm

RE:prime number detector
-----------------------------------
That's called self-handicapping, and that's a bad thing.

-----------------------------------
HeavenAgain
Tue Sep 25, 2007 7:18 pm

RE:prime number detector
-----------------------------------
theres no need to rush
how about try making this code more efficient?
whats the difference between 1x10 and 10x1?
so why bother making your 2nd loop run from the beginning again?
and another small thing, 1 or anything lower are not prime numbers :(

-----------------------------------
Nick
Tue Sep 25, 2007 7:21 pm

RE:prime number detector
-----------------------------------
oh yea... i forgot to run the loop from 2... whoops
anyways Cervantes i usually don't make mistakes and when i do i can usually spot them and fix em easily i was just making a joke
