SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: i<5

Threaded View

  1. #1
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i<5

    3,6,9,12,15,18,21,24,...
    4,8,12,16,20,24,...

    I want message box displays 12.
    Code:
      
    <script type="text/javascript">
    // ortak katların en k&#252;&#231;&#252;ğ&#252;
    Math.leastCommonMultiplier=function(num1,num2){
    for(var i=2; i<5; i++)  if(( i*num1)&#37;num2 ==0) {var same =( i*num1); break;}
    return same;
    }
    
    var n = Math.leastCommonMultiplier(3,4);
    alert(n);  // 12
    var m=Math.leastCommonMultiplier(7,12)
    alert(m);  // returns undefined. it must display 84;
    
    </script>
    m must be 84;
    If I write i<15, message box displays 84.

    I want to write something else instead of i<5
    I try
    for(var i=2; ( i*num1)%num2 !=0; i++) {
    but it returns undefined.
    What can I do? Thanks...
    Last edited by muazzez; Apr 12, 2008 at 02:24.
    Bismillahirrahmanirrahîm
    Bizi doğru yola, kendilerine nimet verdiklerinin yoluna ilet; gazaba uğrayanların ve sapıklarınkine değil.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •