cont = 0 : n = 2 do if is_pow(n, 2) and not is_pow(n, 3) then print n; " "; cont += 1 end if n += 1 until cont = 30 print cont = 0 : n = 2 do if is_pow(n, 2) and is_pow(n, 3) then print n; " "; cont += 1 end if n += 1 until cont = 3 end function is_pow(n, q) #tests if the number n is the q'th power of some other integer r = int(n^(1.0/q)) for i = r-1 to r+1 #there might be a bit of floating point nonsense, so test adjacent numbers also if i^q = n then return true next i return false end function