Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

6 of 9
added 45 characters in body
user avatar
user avatar

Io, (削除) 85 (削除ここまで) 78 bytes

method(i,c :=0;t :=2;while(t<=i,if(i%t<1,c=c+1;while(i%t<1,i=i/t));t=t+1);c<2)

Try it online!

Explanation

method(i, // Take an input
 c := 0 // Hold a counter of prime factors (c)
 t := 2 // Current iteration counter (t, starts from 2)
 while(t<=i, // While the counter is less than i:
 if(i%t<1, // If i is divisible by t:
 c = c + 1 // Increment c
 while(i%t<1, // While i is divisible by t:
 i = i / t // Divide i by t
 )
 )
 t = t + 1 // Increment the counter
 )
 c < 2 // Is the counter equal to 1?
)
user96495

AltStyle によって変換されたページ (->オリジナル) /