Home > bitburner > NS > getPurchasedServerCost
Get cost of purchasing a server.
Signature:
getPurchasedServerCost(ram: number): number;
Parameter | Type | Description |
---|---|---|
ram | number | Amount of RAM of a potential purchased server, in GB. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20). |
Returns:
number
The cost to purchase a server with the specified amount of ram.
RAM cost: 0.25 GB
Returns the cost to purchase a server with the specified amount of ram.
// NS1:
for (i = 1; i <= 20; i++) {
tprint(i + " -- " + getPurchasedServerCost(Math.pow(2, i)));
}
// NS2:
for (i = 1; i <= 20; i++) {
ns.tprint(i + " -- " + ns.getPurchasedServerCost(Math.pow(2, i)));
}