Posted: Thu Feb 24, 2011 6:53 pm Post subject: Primary Divisors Help
Hi
I am making a simple program that finds all the prime divisors of a given number.
Turing:
var test:int var divs :int put"Please enter a number" get test
function prime (a :int):boolean for i :2.. a
if a mod i =0then resultfalse endif endfor resulttrue end prime
procedure find (test :int) for x :2.. test
if test mod x =0then
divs:= test/x
endif endfor if prime(divs)=truethen put divs, " Is a prime divisor of ", test
endif end find
The problem I am having is with the divs = test/x. It says it is the wrong type but if I change it to a real then it doesn`t work in the prime function in the for loop.
Thanks
Sponsor Sponsor
Tony
Posted: Thu Feb 24, 2011 7:29 pm Post subject: RE:Primary Divisors Help