Power Your Software Testing
with AI and Cloud
Supercharge QA with AI for Faster & Smarter Software Testing
A prime number is a number greater than one and divisible only by one or itself. They cannot be divided by anything other than themselves or 1. For example, the prime numbers are 2, 3, 5, 7, 11, 13, 17, etc. However, 0 and 1 are not considered prime numbers. Since all the other even numbers can be divided by 2, therefore 2 is the only even prime number.
Here is the Java program that prints the prime number from 1 to 100.
import java.util.Scanner;
class CheckArmStrongNum {
public static void main(String[] args) {
int num1, k, sum = 0, num;
System.out.println("Enter the number:");
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
num1 = num;
while (num != 0) {
k = num % 10;
sum += Math.pow(k, 3);
num /= 10;
}
if (sum == num1)
System.out.println(num1 + " is an Armstrong number");
else
System.out.println(num1 + " is not an Armstrong number");
}
}
KaneAI - Testing Assistant
World’s first AI-Native E2E testing agent.
Get 100 minutes of automation test minutes FREE!!