Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 prime number detector
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Nick




PostPosted: Tue Sep 25, 2007 4:40 pm   Post subject: prime number detector

I was bored so i made this

Turing:

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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Sep 25, 2007 6:48 pm   Post subject: Re: prime number detector

momop @ Tue Sep 25, 2007 4:40 pm wrote:
all the possiblities to get the number via multiplacation

Those are called factors Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Nick




PostPosted: Tue Sep 25, 2007 6:50 pm   Post subject: Re: prime number detector

lmao whatever it works and i forgot the name Embarassed 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




PostPosted: Tue Sep 25, 2007 7:17 pm   Post subject: RE:prime number detector

That's called self-handicapping, and that's a bad thing.
HeavenAgain




PostPosted: Tue Sep 25, 2007 7:18 pm   Post subject: 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 Sad
Nick




PostPosted: Tue Sep 25, 2007 7:21 pm   Post subject: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: