We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

0

C (gcc), 44-15=29 bytes #define f(x)cos(x*acos(0))+1i*sin(x*acos(0)) Try it online! Handles signed and noninteger arguments.


1

Runic Enchantments, 41 bytes >ii:0)?\S:0)?\:*S:*+'PA@ 3%4A|'S/;$=?4/?3 Try it online! Ended up being a lot easier than I thought and wasn't much room for golfification. The original program I blocked out was: >ii:0)?\S:0)?\:*S:*+'PA@ 3%4A|'S/! S/;$= I played around with trying to compare both inputs at the same time (which saved all of one 1 ...


1

APL(NARS), 99 chars, 198 bytes r←p w;i;k r←0⋄→0×⍳w<2⋄i←2⋄k←√w⋄→3 →0×⍳0=i∣w⋄i+←1 →2×⍳i≤k r←1 f←{v←√k←+/2*⍨⍺⍵⋄0=⍺×⍵:(p v)∧3=4∣v⋄p k} test: 0 f 13 0 0 f 9 0 2 f 3 1 3 f 4 0 0 f 7 1 0 f 9 0 4600 f 5603 1


1

APL(NARS), 58 chars, 116 bytes {1≥k←≢⍵:⍵⋄(∇⍵[y∼⍨⍳k])(+,-)(∇⍵[y←2×⍳t])×0J1*t÷⍨2-2×⍳t←⌊k÷2} test f←{1≥k←≢⍵:⍵⋄(∇⍵[y∼⍨⍳k])(+,-)(∇⍵[y←2×⍳t])×0J1*t÷⍨2-2×⍳t←⌊k÷2} f 1 1 1 1 4J0 0J0 0J0 0J0 f 1 2 3 4 10J0 ¯2J2 ¯2J0 ¯2J¯2 f 1J1 2 ¯2J1 9 10J2 3J7 ¯12J2 3J¯7 f 5.24626,3.90746,3.72335,5.74429,4.7983,8.34171,4.46785,0.760139 36.989359J0 ¯6.211855215J0....


0

APL (Dyalog Unicode), 18 bytes 18 bytes (https://github.com/abrudz/SBCS/) 28 bytes (UTF-8) ⍵ is a complex number ajb = a+bi {⌈/9 11∘.○⍵*0j1-⍵} Try it online!


2

APL (Dyalog Unicode), 36 47 48 49 47 43 28 bytes Takes an array of two integers a b and returns the Boolean value of the statement a+bi is a Gaussian integer. Edit: +11 bytes because I misunderstood the definition of a Gaussian prime. +1 byte from correcting the answer again. +1 byte from a third bug fix. -2 bytes due to using a train instead of a dfn. -4 ...


1

Octave, 109 103 101 100 bytes f(f=@(f)@(x,n=rows(x)){@(d=f(f)(x(k=2:2:n)).*i.^((k*2-4)/n)')[d+(c=f(f)(x(k-1)));c-d],x}{1+(n<2)}()) Try it online! Ooooo do my eyes bleed from this recursive accursed lambda. Large parts of this were lifted from @flawr's answer. f( % lambda function f=@(f) ...


Top 50 recent answers are included