The document contains two Java programs: one that checks if a given number is prime and another that displays all perfect numbers between 1 and a user-defined limit. The first program uses a loop to determine if the number is divisible by any number up to half of itself, while the second program prompts the user for input and checks each number for perfection by summing its divisors. Both programs demonstrate basic Java syntax and control structures.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
12 views2 pages
Assignment 1 Answers
The document contains two Java programs: one that checks if a given number is prime and another that displays all perfect numbers between 1 and a user-defined limit. The first program uses a loop to determine if the number is divisible by any number up to half of itself, while the second program prompts the user for input and checks each number for perfection by summing its divisors. Both programs demonstrate basic Java syntax and control structures.