2016-04-22 58 views

回答

0
WITH RECURSIVE zzz AS (
     SELECT 11::integer AS val 
     UNION ALL 
     SELECT CASE WHEN (zzz.val %2 = 1) THEN 3*zzz.val+1 ELSE zzz.val/2 END AS val 
     FROM zzz 
     WHERE zzz.val <> 1 
     ) 
SELECT * FROM zzz;