MCPcopy
hub / github.com/careercup/ctci / add

Method add

java/Chapter 18/Question18_1/Question.java:5–10  ·  view source on GitHub ↗
(int a, int b)

Source from the content-addressed store, hash-verified

3public class Question {
4
5 public static int add(int a, int b) {
6 if (b == 0) return a;
7 int sum = a ^ b; // add without carrying
8 int carry = (a & b) << 1; // carry, but don�t add
9 return add(sum, carry); // recurse
10 }
11
12 public static int randomInt(int n) {
13 return (int) (Math.random() * n);

Callers 14

mainMethod · 0.95
mainMethod · 0.45
insertStringMethod · 0.45
transformMethod · 0.45
getOneEditWordsMethod · 0.45
setupDictionaryMethod · 0.45
addWordMethod · 0.45
joinToMethod · 0.45
declareMethod · 0.45
initializeMethod · 0.45
addFriendMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected