about positive divisors.
Author |
Message |
appling
|
Posted: 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?
and how to know a number is real or int?? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: 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
|
Posted: Thu Dec 04, 2003 6:10 pm Post subject: (No subject) |
|
|
just use "mod", 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
|
Posted: 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
|
Posted: Thu Dec 04, 2003 6:15 pm Post subject: (No subject) |
|
|
ok,thanks all the same |
|
|
|
|
|
|
|