Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
jcfatorial
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
# Para usar o polinômio de Taylor necessitamos calcular n! para alguns números naturais n. # Aproveitamos isso para apresentar a linguagem de programação que vamos usar. jcfatorial<-function(n){ #jcfatorial é o nome que escolhi para a função que calcula o fatorial de número natural. if (n==0){p=1} # Se n for o retorna o fatorial como 1. else {p=n*jcfatorial(n-1)} # Se n não for 0 retorna n*(n-1)!. p} # Testando a função que construímos. jcfatorial(0) jcfatorial(1) jcfatorial(2) jcfatorial(3) jcfatorial(4) jcfatorial(5) jcfatorial(5) jcfatorial(7)
[
+
]
Show input
Absolute running time: 0.62 sec, cpu time: 0.46 sec, memory peak: 43 Mb, absolute service time: 0,88 sec
edit mode
|
history
|
discussion
[1] 1 [1] 1 [1] 2 [1] 6 [1] 24 [1] 120 [1] 120 [1] 5040