Transposed, primes, oh my!
C, 2*70 2*60
Prints y
for primes, nothing otherwise.
EDIT: Changed code to save 10 chars. Must be run without paramters (so m=1
).
main(m,n){for(scanf("%d",&n);n%++m&&n>1;);n-m||puts("y");}/*
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
The method for handling the transposition is quite generic, and can be applied to any program.
It's based on converting this:
abcd/*
\\\\*/
To this:
a\
b\
c\
d\
/*
*/
And both mean simply abcd
.
C - 13x13
Reads the input from stdin and prints a 1
for prime and a 0
for not prime.
////m(i;(a=)<
////aans")a;2
//:Di)tc%;;p)
//O n{ adfau+
main//bn"o%t4
(a){///f,r-c8
int b///&(-h)
;scanf///bba;
("%d",&///;r}
a);for(b///(
=a;a%--b;//(
);putchar((b
<2)+48);}
edit: compiles with gcc and clang now, other compilers weren't tested
C, 12x12 chars
A two-dimensional solution, unlike my other answer, based on the same code (and like it, prints y
for prime, nothing for composite).
The structure is similar to Quasimodo's answer, but my code is shorter, and I think my usage of comemnts is a bit more efficient, so I can fit 12x12.
////m()s";np
////am{c%n>u
////i,fad%1t
////nnon"+;s
main//rf,+)(
(m,n//((&m;"
){for(//n&ny
scanf(//)&-"
"%d",&n)//m)
;n%++m&&//|;
n>1;);n-m||
puts("y"); }