Advertisement
Guest User

Untitled

a guest
Feb 8th, 2022
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bitcoinMining(array) {
  2.     let daysCounter = 0;
  3.     let totalGold = 0;
  4.     let bitcoins = 0;
  5.     let day = 0;
  6.     let gram = 67.51;
  7.     let totalPrice = 0;
  8.     let firstDay = 0;
  9.     for (let i = 0; i < array.length; i++) {
  10.         day++;
  11.         daysCounter++;
  12.         totalGold = 0;
  13.         if (day % 3 != 0) {
  14.             totalGold += array[i];
  15.         } else if (day % 3 == 0) {
  16.             totalGold += array[i] * 0.7;
  17.         }
  18.         totalPrice = totalPrice + totalGold * gram;
  19.  
  20.         if (totalPrice >= 11949.16) {
  21.             if (bitcoins == 0) {
  22.                 firstDay = daysCounter;
  23.                 while (totalPrice >= 11949.16) {
  24.                     totalPrice -= 11949.16;
  25.                     bitcoins++;
  26.                 }
  27.             } else if (bitcoins >= 1) {
  28.                 while (totalPrice >= 11949.16) {
  29.                     totalPrice -= 11949.16;
  30.                     bitcoins++;
  31.                 }
  32.             }
  33.         }
  34.     }
  35.     console.log(`Bought bitcoins: ${bitcoins}`);
  36.     if (bitcoins >= 1) {
  37.         console.log(`Day of the first purchased bitcoin: ${firstDay}`);
  38.     }
  39.     console.log(`Left money: ${totalPrice.toFixed(2)} lv.`);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement