Product of Odd Integers
Product of Odd Integers
Problem Description
Java Program to find the product of odd integers within the range
Solution,
import java.util.Scanner;
import java.io.*;
public class TestClass {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int p=1;
int a= sc.nextInt();
for(int i=0; i<=a;i++) {
if(i % 2 !=0)
{
p = p * i;
}
}
System.out.println(+p);
}
}
0 Comments