Skip to content

Commit 17a194e

Browse files
committed
sum of two integers solution
1 parent 6df9884 commit 17a194e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sum-of-two-integers/hyer0705.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function getSum(a: number, b: number): number {
2+
while (b !== 0) {
3+
let carry = (a & b) << 1;
4+
5+
a = a ^ b;
6+
7+
b = carry;
8+
}
9+
return a;
10+
}

0 commit comments

Comments
 (0)