28 lines
919 B
JavaScript
28 lines
919 B
JavaScript
/** @param {NS} ns */
|
|
export async function main(ns) {
|
|
//args
|
|
const sTarget = ns.args[0]; // target server
|
|
|
|
ns.tail(ns.pid,"home",ns.args);
|
|
let nMoney = ns.getServerMoneyAvailable(sTarget);
|
|
const nMaxMoney = ns.getServerMaxMoney(sTarget);
|
|
|
|
|
|
|
|
const startValue = nMoney; // First argument: starting value
|
|
const target = nMaxMoney; // Second argument: target value
|
|
let result = startValue; // Initialize result with the starting value
|
|
let n = 1;
|
|
// For loop that continues until the result exceeds or matches the target
|
|
for (; result < target; n++) {
|
|
result += 1; // Add 1 before multiplication
|
|
result *= n; // Multiply by the current step value
|
|
ns.print("result = "+result.toLocaleString() + " / "+ nMaxMoney.toLocaleString());
|
|
ns.print("n = "+n);
|
|
}
|
|
let nGrowThreadsNeeded = n;
|
|
// * ns.growthAnalyze(sTarget, n, 1);
|
|
ns.print("nGrowThreadsNeeded = " + nGrowThreadsNeeded);
|
|
|
|
|
|
} |