WITH t(cnt,val) AS (
SELECT 0,LEVEL FROM DUAL CONNECT BY LEVEL<=POWER(3,10)
UNION ALL
SELECT cnt+1,val/3
FROM t
WHERE MOD(val,1)=0
)
SELECT COUNT(*) FROM t WHERE MOD(val,1)=0 AND cnt>0;
In a country each city has two-way direct flights to maximum three other cities. If every city is reachable from every other city with at most three flights, what can be the maximum number of cities in this country?