Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function test($a, $numbers) {
- $count = 0;
- foreach ($numbers as $v) {
- echo "{$v}</br>";
- if (fmod($v, $_POST['a']) == 0) {
- $count++;
- }
- }
- return $count;
- }
- if (isset($_POST['file']) && isset($_POST['a']) && $_POST['file'] != '' && $_POST['a'] != '') {
- $count = test($_POST['a'], explode("\r\n", $_POST['file']));
- echo "Чисел кратных a={$_POST['a']}: {$count}";
- }
- else { ?>
- <form method="post">
- a:<br/>
- <input name="a"> <br/>
- Файл: (каждое число с новой строки)</br>
- <textarea name="file"></textarea><br/>
- <input type="submit">
- </form>
- <?php } ?>
Add Comment
Please, Sign In to add comment