You could try saving the formula in an array first, then assigning it back to the sheet.
function myFunction() {
sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
range = 'A1:A5';
myFormulas = sheet.getRange(range).getFormulas();
sheet.getRange(range).setFormulas(myFormulas);
}