alts = ...@(n)(-[-1:1]'*[1:n])(n) alts(1)alts(12)alts(77)alts(135)alts(297)
Standard input is empty
alts = @(n) (-[-1:1]' * [1:n]) (n) ans = 1 ans = -4 ans = 0 ans = -45 ans = -99
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!