//Tanzila Islam //Southeast University //mail : tanzilamohita@gmail.com <?PHP if($_SERVER['REQUEST_METHOD']=="POST") { $n = $_POST['num']; $sum = ($n * ($n + 1)) / 2; print("Sum of the series: "); for($i =1;$i <= $n;$i++) { if ($i!=$n) printf("%d + ",$i); else printf("%d = %d ",$i,$sum); } } ?> <form method="post" action=""> Give some input : <input type="text" name="num" /><br /> <input type="submit" value="Submit" /> </form>
No comments:
Post a Comment