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

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 the reduction to 71 bytes.

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

    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!")

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!")

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!")

deleted 1 character in body
Source Link
mousetail
  • 14.4k
  • 1
  • 42
  • 91

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.

  • 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!")

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!")

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!")

added 102 characters in body
Source Link

C (gcc), 119 7171 69 bytes

p;main(a){for(scanf("%d",&p);++a<p;)p=p/a*a-p?p:1;printf1;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!")printf("Try it online!")

C (gcc), 119 71 bytes

p;main(a){for(scanf("%d",&p);++a<p;)p=p/a*a-p?p:1;printf(p-1?"1":"0");} 

Thanks to ceilingcat for the reduction to 71 bytes.


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!")

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!")

deleted 17 characters in body
Source Link
Loading
Source Link
Loading