Skip to main content
5 of 5
They deserve the big credit text stop un-headinging it.

C (gcc), 119 71 69 bytes

p;main(a){for(scanf("%d",&p);++a<p;)p=p/a*a-p?p:1;puts(p-1?"1":"0");} 
  • Thanks to ceilingcat for the reduction to 71 bytes.

  • Thanks to ceilingcat for another 2 bytes shaved off by using puts instead of printf.


Outputs 0 (falsy) when it's composite and 1 (truthy) when it's prime.

My first C answer. To me, it's just a mix of Python and Assembly. Well, at least it's probably not as long as Java...

printf("Try it online!")