7+ JavaScript Cube Root Finder Program Examples

This post contains a total of 7+ Hand-Picked JavaScript Cube Root Finder Program Examples with Source Code. All these Cube root programs are made using JavaScript and Styled using CSS.

You can use the source code of these examples with credits to the original owner.

Related Posts

JavaScript Cube Root Finder Programs

1. Mohammad Amir Aqeel

Made by Mohammad Amir Aqeel. JavaScript Cube Root finder program without using Library Functions. Source

javascript cube root finder program by mohammad amir aqeel
<!DOCTYPE HTML>
<html>
<head>
    <style>
        body {background-color:yellow;}
h3{color:red;
font-size:150%;}
h4{color:red;
font-size:130%;}
label{color:blue;
font-size:130%;}
#output{color:blue;
font-size:150%;}
        </style>
</head>
<body>
<h3>Cube Root Of A Number</h3>
<label>Enter A Number : </label>
<br>
<br>
<input id="num" type="number" placeholder="Enter A Number"/>
<br>
<br>
<button onclick="cube();">Calculate</button>
<h4>Output : </h4>
<div id="output"></div>
<script>
function cube()
{
    var a,b,c,d,e,i,j=1,res=0,f,k,t=10,flag;
    a=document.getElementById("num").value;
    a=parseInt(a);
    if(a<0){
        a+=(-2*a);
        flag=1;
    }
    if(a==2)
        document.getElementById("output").innerHTML=1.2599;
    else{
    for(i=0;i<=a;i++){
        if((i*i*i)==a){
            b=i;
            j=5;
        }
        if((i*i*i)>a){
            b=i-1;
            break;
        }
    }
    c=a-(b*b*b);
    c*=1000;
    res+=b;
    while(j!=5){
        for(k=1;k<c;k++){
            e=(300*b*b)+(30*b*k)+(k*k);
            d=e*k;
            if(d>c){
                k=k-1;
                break;
            }
        }
        e=(300*b*b)+(30*b*k)+(k*k);
        d=e*k;
        f=k/t;
        res+=f;
        c=(c-d)*1000;
        b=res*t;
        t*=10;
        j++;
    }
    if(flag==1){
        res*=(-1);
    } document.getElementById("output").innerHTML=res.toPrecision(5);
    }
}

</script>
</body>
</html>

2. By Vedang

Made by Vedang. Simple Cube root program. Source

javascript cube root finder program by vedang
<!-- MADE BY VEDANG -->

<!DOCTYPE html>
<html>
    <head>
        <link href='https://fonts.googleapis.com/css?family=Major Mono Display' rel='stylesheet'>
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
        <link href='https://fonts.googleapis.com/css?family=Cute Font|Actor|Abel|Alfa Slab One|Thasadith|ZCOOL KuaiLe|IBM Plex Sans|Roboto Mono ' rel='stylesheet'>
        <title>Cube Root</title>
        <style>
            
body {
        color: white;
    font-family: 'Thasadith';
    background-color: #e24d4d;
    text-align: -webkit-center;
animation: animatebottom 2s cubic-bezier(1, -0.06, 0.26, 1.06);
  -webkit-animation: animatebottom 2s cubic-bezier(1, -0.06, 0.26, 1.06);
}
@-webkit-keyframes animatebottom {
0% {

    margin-top:500px;
}
100% {

    margin-top:0px;
}
}

@keyframes animatebottom { 
0% {

    margin-top:500px;
}

100% {

    margin-top:0px;
}}
*{
    outline: none;
}
#p2{
    height: 200px;
    overflow: auto;
    background-color: rgba(0,0,0,0.1);
}
p{
    font-weight:bold;
}
.sidenav {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  background-color: #333;
  overflow-x: hidden;
  transition:.5s cubic-bezier(1, -0.06, 0.26, 1.06);
  padding-top: 30px;
}
.sidenav span, .sidenav a{
  padding: 10px;
  text-decoration: none;
  font-size: 15px;
  color: #818181;
  display: block;
  transition: 0.0s;
  border-radius:0px;
}
.sidenav span:active,.sidenav span:hover, .sidenav a:active, .sidenav a:Hover{
  color: #f1f1f1;
  background-color: #e56464;
  border-radius: 50px;
}
.sidenav .closebtn {
  position: absolute;
  top: 0;
  right: 25px;
  font-size: 36px;
  margin-left: 50px;
}
.topnav {
  overflow: hidden;
  background-color: rgba(0,0,0,0.5);
  position: fixed;
  top:0;
  left:0;
  width:100%;
  z-index:1;
}
.topnav span {
  float: right;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 10px;
  }
  .topnav span:active,.topnav span:hover {
  background-color: #fff;
  color: #555;
}
input{
    border: 0px solid black;
    padding: 8px;
    border-radius: 50px;
    color: #666;
    transition: .3s;
}
input:focus{
    border-radius: 5px;
}
hr{
    border: 4px solid white;
    background: white;
}
a{
    text-decoration:none;
    color: #555;
    font-family: "monospace";
}
h1{
    font-weight: bold;
}
button{
    border: 0px solid black;
    padding: 10px;
    border-radius: 5px;
    background-color: #fff;
    color:#555;
}
button:active{
    background-color: #555;
    color: #fff;
}
            </style>
    </head>
    <body>
    <div class="sidenav" id="mySidenav">
        <p>Other Codes</p>
        <hr>
        <br>
        <a href="https://code.sololearn.com/c2JfQ26o5OFA/?ref=app">Cube Root(c#)</a>
         <a href="https://code.sololearn.com/WYfj5HCw166F/?ref=app">Valid Binary String</a>
        <a href="https://code.sololearn.com/W72XMVj5RGL0/?ref=app">Disarium Number</a>
        <a href="https://code.sololearn.com/Wrju4rsBR0gE/?ref=app">Harshad Number</a>
        <a href="https://code.sololearn.com/WGX8AOl99dGK/?ref=app">Composite Number</a>
        <a href="https://code.sololearn.com/WV9qrzVDwFz2/?ref=app">Gapful Number</a>
    </div>
    
        <div class="topnav">
            <span onclick="openNav()" id="stt">
                <i class='fas fa-bars'></i>
            </span>
        </div>
       <br /><br />
       <main id="ma">
        <h1>Cube Root</h1>
        
        <hr>
        <br>
        <p>
        Enter number in the input below:
        </p>
        
        <input
         id="main"     
         oninput="checkIs(this.value)"
         placeholder="Eg: 1000"
          />
          
        <p id="p"></p>
            
        <br><br>
        <hr>
          <br>
          Made By
    <a href="https://www.sololearn.com/Profile/6426776/?ref=app">VEDANG</a>
    <br><br>
    <br><br><br><br>
    <br><br>
      </main>
      <script>
          
function openNav() {
if( $("mySidenav").style.width == "240px" ){
 closeNav ();
}else{ 
$("ma").style.filter="blur(5px)";
$("mySidenav").style.width = "240px";
$("mySidenav").style.padding = "10px";
$("stt").innerHTML="<i class='far fa-window-close'></i>";
}
}

function closeNav() {
$("ma").style.filter="blur(0px)";
  $("mySidenav").style.padding = "0px";
  $("mySidenav").style.width = "0";
  $("stt").innerHTML="<i class='fas fa-bars'></i>";
}
function checkIs(v){
var x = check(v);
    $('p').innerHTML="Cube Root of "+v+" is <b>"+x+"</b>";
}
function check(n){
    return (Math.pow(n,1/3)).toFixed(4);
}
function $(id){
    return document.getElementById(id);
}
          </script>
    </body>
</html>

3. By Intan

Made by Intan. Source

javascript cube root finder program by intan
<!DOCTYPE html>
<html>
    <head>
        <style>
            body{
    background-color:grey;
    border:2px solid ;
}

.container{padding:15px;}
            </style>
    </head>
<body>
<div class="container">
<input type="number" id="myNumber" placeholder="your number">
<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<div class="foot">
</div>
</div>
<script>
    
function myFunction() {
  var x = document.getElementById("myNumber").value;
 
 y= Math.cbrt(x);
  document.getElementById("demo").innerHTML = y;
}

    </script>
</body>
</html>

4. By Artyom Ryskal

Made by Artyom Ryskal. Basic Program to find Cube root of a Number. Source

javascript cube root finder program by artyom ryskal
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>Cube root</title>
        <script type="text/javascript">
            alert("This code written by Артём Π Ρ‹ΡΠΊΠ°Π»ΡŒ");
            alert("Please sign up and put like");
            function cal() 
            {
                var n = document.getElementById('num').value;
                document.getElementById('res').innerHTML = Math.cbrt(n);
            }
        </script>
        <style type="text/css">
            body {
                background: lightgrey;
            }
            main {
                border: 5px dashed cyan;
                border-radius: 20px;
                text-align: center;
                background: white;
                margin-left: 50px;
                margin-right: 50px;
                margin-top: 140px;
                padding: 5px;
            }
            #num {
                border: 1px solid black;
                height: 20px;
                width: 150px;
                font-size: 18px;
            }
            #send {
                height: 25px;
                width: 100px;
                border: none;
            }
        </style>
    </head>
    <body>
        <main>
            <h2>Enter number</h2>
            <p>
                <form>
                    <input id="num" type="number" name="num" placeholder="For example , 729" autocomplete="off">
                </form>
            </p>
        
            <p>
                <button onclick="cal()" id="send">
                    Calculate
                </button>
            </p>
            
            <p>
                <div id="res">
                    Result
                </div>
            </p>
        </main>
    </body>
</html>

5. By Knw

Made by Knw. Very basic JavaScript program to find cube root. Source

5
1.709975946676697
 var n= prompt("enter the number");
        var x;
        x=Math.pow(n,1/3);
        alert(x);

6. By Fran Extremera

Made by Fran Extremera. JavaScript Cube root finder program without using any libraries. Source

10
The cube root of 10 to a precision of 0.0001 is: 2.1544
var myInput = prompt ("Write the number you need the cubic root of. It can be positive or negative, integer or decimal");

if (myInput < 0){
    var isNegative = true;
    var myInput = myInput *-1;
}

function Power3 (number){
    var result = number * number * number;
    return result;
}

var topValue = 10;

while (Power3 (topValue)< myInput){
    topValue = topValue *10;
}


var bottomValue = 0;
var step = (topValue - bottomValue)/10;
var precision = 0.0001;

while (step >= precision){

    var valueToCheck = bottomValue;

    while (topValue - bottomValue >= step){
        valueToCheck  = valueToCheck + step;
        if (Power3 (valueToCheck) <= myInput){
        bottomValue = valueToCheck;
    
        } else {
        topValue = valueToCheck;
        break;    
        }
    }
    step = step / 10;
}

if (myInput - Power3 (bottomValue) < Power3 (bottomValue + precision) - myInput){
    var solution = bottomValue;
} else {
    var solution = bottomValue + precision;
}

if (isNegative){
    solution = solution * -1;
    var myInput = myInput *-1;
}

alert ("The cube root of "+myInput+ " to a precision of " +precision+ " is: "+ solution.toFixed(4));

7. By Gangineni Goutham Choudary

Made by Gangineni Goutham Choudary. Source

20
The cube root of 20 is 2.7144176165949063
<!DOCTYPE html>
<html>
  <head>
      <style>
          body
{
  font-size: 40pt;
  background-color:black;
}

button{
  height:50px;
  width:150px;
  border-radius:20px;
  background-color:violet;
  
}
          </style>
      <script>
        function ggc()
         {var n = prompt("Enter a number", "");
var answer = Math.cbrt(n);
alert("The cube root of " + n + " is " + answer);}

        </script>
  </head>
  <body>

    <center>

  <button onclick="ggc();"><strong>Find Cube root<br>click here</strong></button>
</center>

  </body>
</html>    

8. By ODG

Made by ODG. Source

javascript cube root finder program by ODG
    document.write("<center><table width=100% cellpadding=0 cellspacing=0><tr><th style='color:lime;background:green'>&nbsp;Cube Root'20180906 &copy; ODG, 2018&nbsp;</th></tr>")
    document.write("</table></center><br>")

    function CubeRoot(n)
      {
        if(n)
          {
            if(n<0)
              {
                n=-n
                Sign='-'
              }
            else
              Sign=''
            var
              uB=n<1?1:n,
              dB=n<1?n:1,
              Old='1',
              New='0'
            while(Old!=New)
              {
                Old=New
                m=(1*uB+1*dB)/2
                //document.write(dB,'-',uB,' ',m,'<br>')
                New=(m*m*m).toFixed(4)
                if(1*New>n)
                  uB=m
                else
                  dB=m
              }
            return Sign+m.toFixed(4)
          }
      }

    var Test=[prompt('Enter number: ',0.6),729,41,2]

    for(i=0;i<Test.length;i++)
      document.write('Cube Root of <b>',Test[i],'</b> is <b>',CubeRoot(Test[i]),'</b><br>')