Skip to content

This Java program identifies integers within a given range that possess one or more of five special mathematical properties. The program iterates from a start to an end value and checks each number against the following five properties. If a number matches at least one, it is printed to the console along with its properties.

Notifications You must be signed in to change notification settings

haidarimahdi/Number_Properties

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Assignment 1: Mathematical Number Properties

This Java program identifies integers within a given range that possess one or more of five special mathematical properties.

Description

The program iterates from a start to an end value and checks each number against the following five properties. If a number matches at least one, it is printed to the console along with its properties.

Properties Checked:

  • Harshad Number: A number that is divisible by the sum of its digits.
  • Happy Number: A number that eventually reaches 1 when replaced by the sum of the square of its digits.
  • Perfect Number: A number that is equal to the sum of its proper divisors. (This program identifies them using two different methods, named 'Nils' and 'Cordula').
  • Hermann Number: A custom-defined number whose binary representation consists of k+1 ones followed by k zeros (for k >= 1).

How to Compile and Run

  1. Navigate to the src directory.
  2. Compile the Java file:
    javac ueb/Main.java
  3. Run the program from the src directory:
    java ueb.Main

The program will then output the numbers in the range of -5 to 500 that match the criteria.

About

This Java program identifies integers within a given range that possess one or more of five special mathematical properties. The program iterates from a start to an end value and checks each number against the following five properties. If a number matches at least one, it is printed to the console along with its properties.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages