Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2018
1,158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. function bitcoinMining(array) {
  2.     let bitcoin = 11949.16;
  3.     let gold = 67.51;
  4.     let totalSum = 0;
  5.     let day = 0;
  6.     let firstDay = 0
  7.     let boughtBitcoin = 0;
  8.     let countBitcoin = 0;
  9.     let sumBitcoins = 0;
  10.  
  11.  
  12.     for (let index = 0; index < array.length; index++) {
  13.         day++;
  14.         let element = array[index];
  15.         if (day % 3 == 0) {
  16.             element = element * 0.7;
  17.         }
  18.         let singleDayEarning = element * gold;
  19.         totalSum += singleDayEarning;
  20.  
  21.  
  22.         if (totalSum >= bitcoin) {
  23.             countBitcoin++;
  24.             boughtBitcoin = Math.floor(totalSum / bitcoin);
  25.             totalSum = totalSum - (bitcoin * boughtBitcoin);
  26.             sumBitcoins += boughtBitcoin;
  27.         }
  28.         if (countBitcoin == 1) {
  29.             firstDay = day;
  30.         }
  31.     }
  32.  
  33.     console.log(`Bought bitcoins: ${sumBitcoins}`);
  34.     if (firstDay != 0) {
  35.         console.log(`Day of the first purchased bitcoin: ${firstDay}`);
  36.     }
  37.     console.log(`Left money: ${totalSum.toFixed(2)} lv.`);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement