• Cursos
  • Compilador de Código
  • Debatir
  • Precios
  • Teams
Menu
0

Optimizing and Shortening Code

How can I optimize the given code which calculates the factorial of a number. https://code.sololearn.com/c7m1MD6M4IsP/?ref=app

factorialoptimize
5th Feb 2020, 4:01 PM
Utkarsh Prajapati
Utkarsh Prajapati - avatar
2 Respuestas
+ 5
I'd go like this. n=1 for i in range(2, int(input()+1)): n*=i print(n) Regard the +1: input of 5 should give 120 as a result, but range(5) stops after 4.
5th Feb 2020, 4:17 PM
HonFu
HonFu - avatar
+ 4
https://code.sololearn.com/c3eg8MvlATAf/?ref=app https://code.sololearn.com/cOInw4yJq7wi/?ref=app https://code.sololearn.com/cE7lXk0wwKMN/?ref=app https://code.sololearn.com/c4phTP2wUQ3u/?ref=app https://code.sololearn.com/cOfMIY803RdZ/?ref=app https://code.sololearn.com/c4Q0rFUFxZIP/?ref=app https://code.sololearn.com/cj7pAcAEmqTm/?ref=app
17th Feb 2020, 2:45 AM
Jesus Eduardo CanulK
Jesus Eduardo CanulK - avatar

¿Tienes a menudo preguntas como esta?

Aprende gratis de forma más eficaz

  • Introducción a Python

    7,1M de estudiantes

  • Introducción a Java

    4,7M de estudiantes

  • Introducción a C

    1,5M de estudiantes

  • Introducción a HTML

    7,5M de estudiantes

Ver todos los cursos
En tendencia hoy
Mobile number and similarity
0 Votes
Can I import any module in python in this app?
0 Votes
GitHub account connecting issue
3 Votes
photo upload issue in html code
0 Votes
Algorithm to create maze-like grid
2 Votes
Converter minúsculas em maiúsculas e imprimir
0 Votes
Coding issue
2 Votes
Loops and conditions
0 Votes
Alguém Português por aqui?
0 Votes
Hardware of computer
3 Votes