Assignment 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

ASSIGNMENT 1

Date : 03.03.2021 Date of Submission: 08.03.2021


Submit in the form of Jupyter Note. Roll Number and Name must be in the First
line.

1.Write a program to find the perfect numbers within a given number range. In
number theory, a perfect number is a positive integer that is equal to the sum of
its proper positive divisors, that is, the sum of its positive divisors excluding the
number itself (also known as its aliquot sum). Equivalently, a perfect number is a
number that is half the sum of all of its positive divisors (including itself).
Example : The first perfect number is 6, because 1, 2, and 3 are its proper
positive divisors, and 1 + 2 + 3 = 6. Equivalently, the number 6 is equal to half the
sum of all its positive divisors: ( 1 + 2 + 3 + 6 ) / 2 = 6. The next perfect number is
28 = 1 + 2 + 4 + 7 + 14. This is followed by the perfect numbers 496 and 8128.

2. Write a Program to display the pattern like pyramid using the alphabet.
A
A B A
A B C B A
A B C D C B A

3. Write a program to convert a decimal number into binary without using


list/tuple/dictionary

4. Write a program to find the strong numbers within a given number range.
Strong numbers are those numbers whose sum of factorial of each digits is equal to the
original number. Strong Number Examples, 1 is strong number because 1!= 1, 2 is strong
number i.e. 2! ... List of Strong Numbers: 1, 2, 145, 40585, ....

5. A perfect number is a number for which the sum of its proper divisors is
exactly equal to the number. For example, the sum of the proper divisors of 28
would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.

A number n is called deficient if the sum of its proper divisors is less than n and it
is called abundant if this sum exceeds n.
As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest
number that can be written as the sum of two abundant numbers is 24. By
mathematical analysis, it can be shown that all integers greater than 28123 can
be written as the sum of two abundant numbers. However, this upper limit cannot
be reduced any further by analysis even though it is known that the greatest
number that cannot be expressed as the sum of two abundant numbers is less
than this limit.

Find the sum of all the positive integers which cannot be written as the sum of
two abundant numbers.

6. The following iterative sequence is defined for the set of positive integers:

n → n/2 (n is even)
n → 3n + 1 (n is odd)

Using the rule above and starting with 13, we generate the following sequence:

13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1

It can be seen that this sequence (starting at 13 and finishing at 1) contains 10


terms. Although it has not been proved yet (Collatz Problem), it is thought that all
starting numbers finish at 1.

Which starting number, under one million, produces the longest chain?

NOTE: Once the chain starts the terms are allowed to go above one million.

You might also like