• 23-03-2010, 21:32:05
    #10
    Üyeliği durduruldu
    geldim okuldan şimdi : ) söylediğim gibi javada yapmıştım ben algoritması anlaşılır sanırım zaten php olarakta yapabiliriz tabi ki .
    bu kadar veri tipi dönüş tipi yazmak zorunda kalmazdık ayrı mesele

    system.out.println(matematik.KareKok(5));
    public class matematik {
        public static double Ussu(double sayi, int us) {
            double sonuc = 1;
            for (int i = 1; i <= us; i++)
                sonuc *= sayi;
            return sonuc;
        }
        public static double KareKok(float sayi) {
    
            double us = 0;
            int temp = 1;
            Boolean tamamdir = false;
            for (int i = 1; i <= sayi; i++) {
                us = matematik.Ussu(i, 2);
                if (us == sayi) {
                    tamamdir = true;
                    temp = i;
                    break;
                } else if (us > sayi) {
                    break;
                }
                temp = i;
            }
            double don = temp;
            if (tamamdir == false) {
                double us2 = 0;
                for (double j = us; j > temp; j = j - 0.01) {
                    us2 = matematik.Ussu(j, 2);
                    if (us2 <= sayi) {
                        don = j;
                        break;
                    }
                }
            }
            return don;
        }
    
    }
  • 24-03-2010, 01:50:07
    #11
    Fonksiyon değil + elle yazdım biraz () + "tam" sayıyı bulamıyorum ama genellikle (2-3 sayı hariç) istediğim rakamı veriyor:

    <?php
    
    for ($n = 1; $n <= 100; $n++)
    {
    	$x0 = (strlen($n)) * 10 * 10;
    	$x1 = 0.5 * ($x0 + ($n / $x0));
    	$x2 = 0.5 * ($x1 + ($n / $x1));
    	$x3 = 0.5 * ($x2 + ($n / $x2));
    	$x4 = 0.5 * ($x3 + ($n / $x3));
    	$x5 = 0.5 * ($x4 + ($n / $x4));
    	$x6 = 0.5 * ($x5 + ($n / $x5));
    	$x7 = 0.5 * ($x6 + ($n / $x6));
    	$x8 = 0.5 * ($x7 + ($n / $x7));
    	$x9 = 0.5 * ($x8 + ($n / $x8));
    	echo '<table>';
    	echo '<tr><td>'; echo 'Number: '; echo '</td><td>'; echo $n; echo '</td></tr>';
    	echo '<tr><td>'; echo 'My sqrt: '; echo '</td><td>';  echo round($x9, 5); echo '</td></tr>';
    	echo '<tr><td>'; echo 'sqrt(): '; echo '</td><td>'; echo round(sqrt($n), 5); echo '</td></tr>';
    	echo '<tr><td>----</td></tr>';
    	echo '</table>';
    }
    
    ?>
  • 25-03-2010, 15:56:29
    #12
    KeLKuN adlı üyeden alıntı: mesajı görüntüle
    Fonksiyon değil + elle yazdım biraz () + "tam" sayıyı bulamıyorum ama genellikle (2-3 sayı hariç) istediğim rakamı veriyor:

    <?php
     
    for ($n = 1; $n <= 100; $n++)
    {
        $x0 = (strlen($n)) * 10 * 10;
        $x1 = 0.5 * ($x0 + ($n / $x0));
        $x2 = 0.5 * ($x1 + ($n / $x1));
        $x3 = 0.5 * ($x2 + ($n / $x2));
        $x4 = 0.5 * ($x3 + ($n / $x3));
        $x5 = 0.5 * ($x4 + ($n / $x4));
        $x6 = 0.5 * ($x5 + ($n / $x5));
        $x7 = 0.5 * ($x6 + ($n / $x6));
        $x8 = 0.5 * ($x7 + ($n / $x7));
        $x9 = 0.5 * ($x8 + ($n / $x8));
        echo '<table>';
        echo '<tr><td>'; echo 'Number: '; echo '</td><td>'; echo $n; echo '</td></tr>';
        echo '<tr><td>'; echo 'My sqrt: '; echo '</td><td>';  echo round($x9, 5); echo '</td></tr>';
        echo '<tr><td>'; echo 'sqrt(): '; echo '</td><td>'; echo round(sqrt($n), 5); echo '</td></tr>';
        echo '<tr><td>----</td></tr>';
        echo '</table>';
    }
     
    ?>
    ha şu yabanci sitedeki şu functionu isteyen senmiydin
     
     
    <?php
    function mysqrt($xxx,$top,$round)
    {
    $content='';
    for ($n = 1; $n <= $xxx; $n++)
    {
         $x0 = (strlen($n)) * 10 * 10;
    
    for($i=0;$i<=$top;$i++)
    {
    if($i=='0')
    {    
    $x1x[$i] = 0.5 * ($x0 + ($n / $x0)); 
    }
    else
    {
         $x1x[$i] = 0.5 * ($x1x[$i-1] + ($n / $x1x[$i-1]));
    }
    
    }
    $topitop=$x1x[$top];
    
    $content.= "<table>\n";
    $content.= "<tr><td> Number: </td><td>" . $n . "</td></tr>\n";
    $content.= "<tr><td>My sqrt: </td><td>" . round($topitop, $round) . "</td></tr>\n";
    $content.= "<tr><td> sqrt(): "."</td><td>" . round(sqrt($n), $round) . "</td></tr>\n";
    $content.= "<tr><td>----</td></tr>\n";
    $content.= "</table>\n\n";
    }
    return $content;
    }
    
    echo mysqrt(100,10,5);
    ?>
  • 25-03-2010, 17:23:38
    #13
    Tontonq adlı üyeden alıntı: mesajı görüntüle
    ha şu yabanci sitedeki şu functionu isteyen senmiydin
     
     
    <?php
    function mysqrt($xxx,$top,$round)
    {
    $content='';
    for ($n = 1; $n <= $xxx; $n++)
    {
         $x0 = (strlen($n)) * 10 * 10;
    
    for($i=0;$i<=$top;$i++)
    {
    if($i=='0')
    {    
    $x1x[$i] = 0.5 * ($x0 + ($n / $x0)); 
    }
    else
    {
         $x1x[$i] = 0.5 * ($x1x[$i-1] + ($n / $x1x[$i-1]));
    }
    
    }
    $topitop=$x1x[$top];
    
    $content.= "<table>\n";
    $content.= "<tr><td> Number: </td><td>" . $n . "</td></tr>\n";
    $content.= "<tr><td>My sqrt: </td><td>" . round($topitop, $round) . "</td></tr>\n";
    $content.= "<tr><td> sqrt(): "."</td><td>" . round(sqrt($n), $round) . "</td></tr>\n";
    $content.= "<tr><td>----</td></tr>\n";
    $content.= "</table>\n\n";
    }
    return $content;
    }
    
    echo mysqrt(100,10,5);
    ?>
    Ta kendisi
  • 01-04-2010, 19:22:21
    #14
    Üyeliği durduruldu
    teşekkürler katılan arkadaşlara =)