RosettaCodeData/Task/Attractive-numbers/Craft-Basic/attractive-numbers.basic

49 lines
454 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
for x = 1 to 120
2026-04-30 12:34:36 -04:00
let n = x
let c = 0
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
do
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
if int(n mod 2) = 0 then
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
let n = int(n / 2)
let c = c + 1
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
endif
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
wait
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
loop int(n mod 2) = 0
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
for i = 3 to sqrt(n) step 2
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
do
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
if int(n mod i) = 0 then
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
let n = int(n / i)
let c = c + 1
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
endif
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
wait
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
loop int(n mod i) = 0
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
next i
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
if n > 2 then
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
let c = c + 1
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
endif
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
if prime(c) then
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
print x, " ",
2023-07-01 11:58:00 -04:00
2026-04-30 12:34:36 -04:00
endif
2023-07-01 11:58:00 -04:00
next x