Apply for Zend Framework Certification Training

Php Questions





<p><span style="background-color:rgb(255, 255, 255); color:rgb(51, 51, 51); font-family:noto serif,serif; font-size:19px">We need first store the current number to a variable. And then we will find the remainder for each division of other numbers with the stored number using a loop. And we will increment a counter if remainder found zero. After all the division operations with other numbers we will check the total counter for the remainder. If its value greater than two means , that number can be divisible by some other number instead of 1 and that number itself.If its value less than three means , its a primer number.</span></p>
                                    

for($i=2;$i<=100;$i++){
        $flag = 0;
        for($j=2;$j<$i;$j++){
            $rem = $i%$j;
            echo $rem.',';
            if($rem == 0){
                $flag++;
            }
        }
        if($flag == 0){
            echo $i.'- ';
            echo "<br>";
        }
    }

< PHP Fibonacci Series Codeigniter: Create your custom library | webphpleaern >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top