JavaScript Scripts





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Free Java Script Codes
Javascript List All
Slide Show Slide Show
Ad Display Ad Display
Image Effect Image Effect
Animated Image Effects Animated Image Effects
Form Validation Form Validation
Color Picker Tool Color Picker Tool
Formatting Forms Formatting Forms
Select All Select All
Dynamic Form Select Dynamic Form select
Dynamic Color Dynamic Color
Calendar Script Calendar
Textbox Counter Textbox Counter
Alphanumeric Alphanumeric
Date Time Script Date & Time
Stop Watch Script Stop Watch script
Delete Repeated Values Delete Repeated Values
Pagination Pagination
Random Generator Random Generator
Animated Text Animated Text
Cursor Position Cursor Position
User Info Window / User Info
Security Security / Authenticate
Bookmark Bookmark
Mouse Effects Mouse Effects
Title Bar Title Bar
Status Bar Status Bar
Country List Country List
Free Games Free Games
Calculators Calculators
 




Javascript LCM Calculator


About
  LCM calculator is used to find the least common denominator of given positive numbers, Since it is a multiple, it can be divided by given numbers without a remainder.


Features
a) Used to calculate the smallest multiple of two or more numbers.
b) Handy tool to determine the least common denominator (LCD) of given numbers.
c) This works fine for natural numbers.

Preview

LCM/LCD Calculation :
Number of Values:
H



Code
Javascript Code
<!-- Script by hscripts.com -->
<!-- Copyright of HIOXINDIA -->
<!-- More scripts @www.hscripts.com -->
<script type="text/javascript">
function calculate()
{
   var tot=document.getElementById("tot").value;
   var count=2;
   if(tot>1){
     var n1=document.getElementById("txt0").value;
     var n2=document.getElementById("txt1").value;
     var res1=n1*n2;
     n1=calc(n1,n2);
     lcm=res1/n1;
     while(count<tot){
        var gg="txt"+count;
        n2=document.getElementById(gg).value;
        res1=lcm*n2;
        n1=calc(n1,n2);
        var lcmv=calc(lcm,n2);
        lcm=res1/lcmv;
        count=count+1;
     }  
   }
   document.getElementById("re").style.display="block";
   document.getElementById("resul").value=lcm;
}
function calc(n1,n2)
{
  var num1,num2;
  if(n1 < n2){ 
      num1=n1;
      num2=n2;  
   }
   else{
      num1=n2;
      num2=n1;
    }
  var remain=num2%num1;
  while(remain>0){
      num2=num1;
      num1=remain;
      remain=num2%num1;
  }
  return num1;
}  
function newtextbox(val)
{
  if(val<6){
     var dd=document.getElementById('new1'); 
     var en=document.getElementById('va').style.display='block';
     if(dd.innerHTML==""){
       for(var i=0;i<val;i++)
       {
          var textbox=document.createElement('input');
          textbox.setAttribute("type","text");
          var textname="txt"+i;
          textbox.setAttribute("id",textname);
          textbox.setAttribute("size","4");
          dd.appendChild(textbox);
       }
     }
     else{
       for(var i=0;i<val;i++)
       {
           var gg="txt"+i;
           dd.removeChild(document.getElementById(gg));
           document.location.reload(); 
       }
     }
   } 
   else{
     alert("Enter values upto 5 only");
   }
}
</script>

<!-- Script by hscripts.com -->


HTML Code
<table align=center style='border:1px solid green;color: #3D366F;font-size:13px;'>
<form name=frm>
<tr><td>Total Numbers:</td><td><input type="text" id="tot" name="tot" value="" size="4" onkeyup="newtextbox(this.value)"></td></tr>
<tr><td id=va style='display:none;'>Values:</td><td id='new1'></td></tr>
<tr><td align=center colspan=2><input type="button" onclick="calculate()" value="LCM"><a href='http://hscripts.com' style='text-decoration:none;font-size:10;color:green;'>H</a></td></tr>
<tr><td align=right id=re colspan=2 style='display:none;'>LCM of the above numbers:<input type="text" name="resul" id="resul" value="" readonly size="4"></td></tr>
</form>
</table>

Release Date - 30-07-2009
Get free version without ©copyright link for just 5 price

For customization of this script or any script development, contact us at support@hscripts.com


Usage
 a) By Copying the javascript code into your HTML page, you can make use of this script to find the smallest multiple of given number.
 b) Here,the function "calculate()" is used to find the least common denominator of the given numbers.
 c) This is a simple calculator, all done with a button click to find LCD .



License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.
Other Links

web hosting