Puzzles/Sum of a Vector

From J Wiki
Jump to navigation Jump to search

Find the sum of a non-empty numeric vector v without using the character + . Currently, 10 essentially different solutions are listed below.

Spoiler Alert!









































Solutions

Expression Comment
 ".(43{a.)'/v' a "cheat"
 (--)/v the dyad (--) is plus
 -/v*(#v)$1 _1 alternating sum
 1#.v

 v p. 1

power series evaluated at 1
 v%.1
 *&.^/v

 */&.:^v

works if v are real numbers
 #v#1

 #I.v

works if v are non-negative integers
 >:@[&0/v works if v are non-negative integers
 (>:@$: <:)`[@.(0=])/v

 (>:@$: <:)~^:(0<[)/v

works if v are non-negative integers; based on the Peano axioms
 ((*.,0:) $:&#. ~:)/@#:@,^:(0<[)/v works if v are non-negative integers; implements addition on binary representations