0% found this document useful (0 votes)
6 views2 pages

Program (1)

The document contains two Java programs. The first program checks if a given number is prime, while the second program computes and prints the first ten terms of a Fibonacci-like sequence based on two input numbers. Both programs utilize the Scanner class for user input.
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
6 views2 pages

Program (1)

The document contains two Java programs. The first program checks if a given number is prime, while the second program computes and prints the first ten terms of a Fibonacci-like sequence based on two input numbers. Both programs utilize the Scanner class for user input.
Copyright
© © All Rights Reserved
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
You are on page 1/ 2

Program:1

package org.program;
import java.util.Scanner;
public class Program1 {
public static void main(String[] args) {
Scanner n = new Scanner(System.in);
System.out.println("Enter the number of prime
number:");
int num = n.nextInt();
System.out.println(num);
boolean prime= true;
int a=2;
while(a<num)
{
if(num%a==0)
{

System.out.println("Prime number is
false");
prime=false;
break;
}
a++;
}
if (prime==true) {
System.out.println("prime number is
true");

}
}

}
Program :2
package org.program;
import java.util.Scanner;
public class Program1 {
public static void main(String[] args) {
Scanner n = new Scanner(System.in);
System.out.println("Enter the number:");
int num = n.nextInt();
Scanner n2 = new Scanner(System.in);
System.out.println("Enter the number:");
int numb = n.nextInt();
for (int i = 1; i <=10; i++) {
System.out.println(num);

int fact = num+numb;


num=numb;
numb= fact;

}
}

You might also like