Computer Science Canada

about positive divisors.

Author:  appling [ 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??

Author:  Dan [ Thu Dec 04, 2003 5:47 pm ]
Post 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

Author:  appling [ Thu Dec 04, 2003 6:10 pm ]
Post 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??

Author:  Dan [ Thu Dec 04, 2003 6:12 pm ]
Post 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.

Author:  appling [ Thu Dec 04, 2003 6:15 pm ]
Post subject: 

ok,thanks all the same


: