How do I create a conditional formula for Google Spreadsheets where:
If the value of cell A1 is an even number, I want cell B2 to display the value of A1 * 2
If the value of cell A1 is an odd number, I want cell B2 to display the value of A1 + 1
Here's a basic blueprint for what I want to do:
function isEven(input) {
if(input % 2 == 0) {
return true;
}
else {
return false;
}
}
function conditionalFormula(input) {
if(isEven(input)) {
//Make cell B1's value equal to A1 * 2
}
else {
//Make cell B1's value equal to A1 + 1
}
}
return input+1orreturn input*2respectively.