0% found this document useful (0 votes)
23 views

Assignment1 Computer

The document contains 6 problems related to number manipulation in Java: 1. Write a program to check if a number is special and print special numbers between limits. 2. Write a program to count abundant, deficient, and perfect numbers between limits. 3. Write a program to print numbers in a special series up to 20000. 4. Write a program to print numbers between limits that can be expressed as the sum of two cubes in multiple ways. 5. Write a program to check if two numbers are amicable. 6. Write a program to check if a number is a Disarium number.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Assignment1 Computer

The document contains 6 problems related to number manipulation in Java: 1. Write a program to check if a number is special and print special numbers between limits. 2. Write a program to count abundant, deficient, and perfect numbers between limits. 3. Write a program to print numbers in a special series up to 20000. 4. Write a program to print numbers between limits that can be expressed as the sum of two cubes in multiple ways. 5. Write a program to check if two numbers are amicable. 6. Write a program to check if a number is a Disarium number.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 1 on number manipulation

1. Write a Java program to check whether a given number is a special number. In number
system, special numbers are positive numbers whose only prime factors are 2, 3 or 5.
First few special numbers are 2, 3, 4, 5, 6, 8, 9, 10, 12. Your program should print the
special numbers between two given limits.
2. Write a Java program to PRINT total number of Abundant, Deficient and Perfect
numbers between two given limits
Abundant Number In number theory, an abundant number is a number for which the
sum of its proper divisors is greater than the number itself.
Example :
For ex The integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6
for a total of 16.
Deficient Number : In number theory, an deficient number is a number for which the
sum of its proper divisors is less than the number itself.
For ex The integer 21 is a deficient number. Its proper divisors are 1, 3,7 and for a total
of 11.

Perfect Number: In number system, 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.
The first perfect number is 6. Its proper divisors are 1, 2, and 3, and 1 + 2 + 3 = 6.

3. Write a Java program to print the numbers of a special series.


In mathematics, the special series are an infinite sequence of integers. The sequence of
numbers in the series starts with 0 and 1, and then each number in the series is the sum
of twice the previous number and the number before that.:
The first few terms of the sequence are :
0, 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741, 13860,……. Thus, 70 = 2 × 29 + 12 =
58 + 12.. Your program should print all the numbers of the series <= 20000, starting from
0.

4. Write java program to print numbers between two given limits(L and U) that can be
expressed as the sum of two cubes in two (or more) different ways. (L should be >=1700
and U<= 50000) . The program should print an error message if the lower and upper limit
are out of range.

1729 = 1^3 + 12^3 = 9^3 + 10^3


4104 = 2^3 + 16^3 = 9^3 + 15^3
13832 = 2^3 + 24^3 = 18^3 + 20^3
39312 = 2^3 + 34^3 = 15^3 + 33^3

5. Write a Java program to check if two numbers are Amicable numbers or not. Amicable
numbers are two different numbers so related that the sum of the proper divisors of each
is equal to the other number.
The first ten amicable pairs are: (220, 284), (1184, 1210), (2620, 2924), (5020, 5564),
(6232, 6368), (10744, 10856), (12285, 14595), (17296, 18416), (63020, 76084), and
(66928, 66992).The smallest pair of amicable numbers is (220, 284). They are
amicable because the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and
110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71 and 142,
of which the sum is 220.
6. Write a Java program to check whether a given number is a Disarium number or not. A
Disarium number is a number defined by the following process :
Sum of its digits powered with their respective position is equal to the original number.
For example 175 is a Disarium number :
As 11+72+53 = 175

You might also like