Developed by JavaTpoint. Now, let’s get into the programming part. , which is equal to the product of all positive integers less than or equal to X. i.e. It is denoted with a (!) Java code for calculating Factorial using a user-defined method(using function). Here a C++ program is given to find out the factorial of a given input using dynamic programming. Here, 4! Java Program To Calculate Factorial using standard values with outputs. This is a Java program to find the factorial of a Number using for loop. The Knapsack problem An instance of the knapsack problem consists of a knapsack capacity and a set of items of varying Dynamic Programming in Java.