RosettaCodeData/Task/Square-but-not-cube/Fennel/square-but-not-cube.fennel
2026-04-30 12:34:36 -04:00

22 lines
634 B
Fennel

(do ;;; list the first 30 numbers that are squares but not cubes
;;; also indicate the numbers that are both squares and cubes
(local maxCount 30)
(var (count c c3 s sq) (values 0 1 1 0))
(while (< count maxCount)
(set s (+ s 1))
(set sq (* s s))
(while (< c3 sq)
(set c (+ c 1))
(set c3 (* c c c))
)
(io.write (string.format "%5d" sq))
(if (= c3 sq)
(io.write (.. " is also the cube of " c))
;else
(set count (+ count 1))
)
(io.write "\n")
)
)