Лабораторная работа 4: Текстовые файлы. Факторизация, простые числа, разные задачи. вариант 3
Описание
Цель работы (Вариант 3)
Выполнить задания в соответствии с вариантом №3, изучив факторизацию, работу с текстовыми файлами, простыми числами с помощью интерпретатора Hugs языка программирования Haskell; реализовав различные программы с сайта1. Строки исходного файла, выровненные справа.
2. (21) Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
Evaluate the sum of all the amicable numbers under 10000.
3. (200) We shall define a sqube to be a number of the form, p2q3, where p and q are distinct primes.
For example, 200 = 5223 or 120072949 = 232613.
The first five squbes are 72, 108, 200, 392, and 500.
Interestingly, 200 is also the first number for which you cannot change any single digit to make a prime; we shall call such numbers, prime-proof. The next prime-proof sqube which contains the contiguous sub-string "200" is 1992008.
Find the 200th prime-proof sqube containing the contiguous sub-string "200".
Показать/скрыть дополнительное описаниеЦель работы (Вариант 3) Выполнить задания в соответствии с вариантом №3, изучив факторизацию, работу с текстовыми файлами, простыми числами с помощью интерпретатора Hugs языка программирования Haskell; реализовав различные программы с сайта http://projecteuler.net/problems. 1. Строки исходного файла, выровненные справа. 2. (21) Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284.
The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. Evaluate the sum of all the amicable numbers under 10000. 3. (200) We shall define a sqube to be a number of the form, p2q3, where p and q are distinct primes. For example, 200 = 5223 or 120072949 = 232613. The first five squbes are 72, 108, 200, 392, and 500. Interestingly, 200 is also the first number for which you cannot change any single digit to make a prime; we shall call such numbers, prime-proof. The next prime-proof sqube which contains the contiguous sub-string \"200\" is 1992008. Find the 200th prime-proof sqube containing the contiguous sub-string \"200\"..