This Java command-line application analyzes a range of integers to identify specific number theory properties and applies a custom bitwise encryption algorithm. The program is a practical exercise in algorithmic thinking, number theory, and low-level bit manipulation.
The application iterates through a predefined numerical range and performs the following tasks:
-
Number Theory Analysis: It filters for prime numbers and negative numbers and then checks them for two unique properties:
- Emirp Numbers: A prime number that results in a different prime number when its decimal digits are reversed (e.g., 13 is prime, and its reverse, 31, is also prime).
- Twin Primes: A prime number
p
where eitherp-2
orp+2
is also a prime number (e.g., 17 is a twin prime because 19 is also prime).
-
Custom Bitwise Encryption: The program implements a custom encryption scheme that demonstrates a deep understanding of bit manipulation.
- It takes a 32-bit integer and breaks it into four separate 8-bit chunks (bytes).
- Each 8-bit chunk is then individually encrypted using a bitwise XOR (
^
) operation with a provided 8-bit key. - The four encrypted chunks are then reassembled into the final 32-bit integer.
-
Formatted Console Output: The results are printed to the console in a clean, aligned table, showcasing the identified properties and the encrypted value alongside its custom-formatted binary representation.
This project showcases several key programming and computer science concepts:
- Number Theory: Implementation of algorithms for primality testing, number reversal, Emirps, and Twin Primes.
- Bit Manipulation: A strong understanding of low-level data operations, including XOR encryption, bitmasking (
&
), and bit shifting (<<
,>>>
). - Algorithmic Thinking: Designing clear, procedural solutions for each of the program's distinct tasks.
- Procedural Programming: The code is well-organized into a collection of static methods, each with a single, clear responsibility.
- Formatted I/O: Effective use of
printf
to produce readable and well-structured command-line output.
To run this application, you will need a Java Development Kit (JDK) installed.
-
Navigate to the
src
directory from your terminal:cd Number_Properties_And_Encryption/src
-
Compile the Java source file:
javac ueb/Main.java
-
Execute the program. Note that all parameters (start, end, key) are currently hard-coded as constants within
main()
:java ueb.Main
The program will then execute and print the formatted analysis of the numbers in the specified range directly to your console.