Skip to main content

TOP 10 Mostly asked Basic Programs in python

 

1. Python Program for factorial of a number

Factorial of a number is products of all natural number to till that number.
for eg:
5!=5*4*3*2*1=120
100!=1*2*3*...........................................99*100

Logic: Suppose we have to find the the factorial of a number n then we required to multiply all number starting from 1 to n
n!=1*2*3*4*.........................(n-1)*n!
So we need to multiply all these numbers in this range 1 to n+1
why did I not  take range 1 to n because range function gives values less than 1 
OUTPUT:

Implementation using Loop

                                                         Implementation using  Recursion


Comments

Popular posts from this blog

Introduction to Machine Learning

What is Machine learning? The meaning of Machin Learning is machine learns itself with its experience.  Machine learning (ML) is a type of artificial intelligence (AI) that allows software applications to become more accurate at predicting outcomes without being explicitly programmed to do so. ML improve the performance of a computer program using sample data or past experience.  We have to create a model and then we have to train the model which will provide the prediction on the basis of machine learning algorithms. For eg: A robot learns with its past experience and improve itself.   Classification of Machine Learnings algorithms: Supervised Learning: Supervised learning, as the name indicates, has the presence of a supervisor as a teacher.  It is defined by its use of labelled datasets to train algorithms that to classify data or predict outcomes accurately. For eg:   Supposed to identify the fruits in the basket we mu...