Ethiopian multiplication: Difference between revisions

m
→‎{{header|Java}}: No need to loop twice, and the table is still saved in the map if you want to debug later
(Added Object Pascal)
m (→‎{{header|Java}}: No need to loop twice, and the table is still saved in the map if you want to debug later)
Line 1,086:
 
Map<Integer, Integer> columns = new HashMap<Integer, Integer>();
columns.put(first, second);
int sum = isEven(first)? 0 : second;
do{
first = halveInt(first);
second = doubleInt(second);
columns.put(first, second);
if(!isEven(entry.getKey()first)){
}while(first != 1);
int sum += 0second;
 
int sum = 0;
for(Map.Entry<Integer, Integer> entry : columns.entrySet()){
if(!isEven(entry.getKey())){
sum += entry.getValue();
}
}while(first != 1);
System.out.println(sum);
}
Anonymous user