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

Username:   Password: 
 RegisterRegister   
 about positive divisors.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
appling




PostPosted: Thu Dec 04, 2003 5:38 pm   Post subject: about positive divisors.

first it randint a lot of numbers,then, i want to display those numbers that the numbers' positive divisors (factors) is 3.

HOw could i do that? Question Question
and how to know a number is real or int??
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Thu Dec 04, 2003 5:47 pm   Post subject: (No subject)

i am not 100% shure of what you are asking but may be this is close?

code:

var temp : int

for i : 1 .. 10
    temp := Rand.Int (1, 100)

    put temp, " - " ..

    if temp mod 3 = 0 then
        put "can be div by 3"
    else
        put "can NOT be div by 3"
    end if

end for


the mod comand returns the reamned of the 1st therem div the 2nd
if the renamder is 0 then it diveds evenealy in to it
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
appling




PostPosted: Thu Dec 04, 2003 6:10 pm   Post subject: (No subject)

just use "mod", Very Happy Very Happy i forget it, thank u very much
but please help me with the 2nd questions-------how to know a number is real or int??
Dan




PostPosted: Thu Dec 04, 2003 6:12 pm   Post subject: (No subject)

well that may be hard, since if you input it as a int and it is real turing will crash. you best bet is to input a number as a real number then round it no matter what if using it for somting that needs to be int.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
appling




PostPosted: Thu Dec 04, 2003 6:15 pm   Post subject: (No subject)

ok,thanks all the same
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: