forked from joanby/r-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
458 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
opBasic = function(a,b){ | ||
print("Suma") | ||
print(a+b) | ||
print("Resta") | ||
print(paste(sprintf("%i - %i = ",a,b),a-b)) | ||
print(paste(sprintf("%i - %i = ",b,a),b-a)) | ||
print("Producto") | ||
print(a*b) | ||
print("Cociente de la división entera") | ||
print(paste(sprintf("%i : %i = ",a,b),a%/%b)) | ||
print(paste("con resto ",a%%b)) | ||
print("Cociente de la división entera") | ||
print(paste(sprintf("%i : %i = ",b,a),b%/%a)) | ||
print(paste("con resto ",b%%a)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: "Binomio de Newton" | ||
author: "María Santos" | ||
date: "30/12/2018" | ||
output: html_document | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
knitr::opts_chunk$set(echo = TRUE) | ||
``` | ||
|
||
# PRODUCTO NOTABLE | ||
|
||
La fórmula del producto notable es | ||
|
||
$$(a+b)^2 = a^2+2ab+b^2$$ | ||
|
||
# Función con R | ||
|
||
```{r} | ||
binomioNewton2 = function(a,b){ | ||
a^2+2*a*b+b^2 | ||
} | ||
binomioNewton2(1,2) | ||
binomioNewton2(2,1) | ||
``` | ||
|
||
# BINOMIO DE NEWTON | ||
|
||
$$(a+b)^n = \sum_{k=0}^n {n\choose k}\cdot a^{n-k}\cdot b^k = {n\choose 0}\cdot a^n\cdot b^0+\cdots {n\choose n}\cdot a^0\cdot b^n$$ | ||
|
||
# Función con R | ||
|
||
```{r} | ||
binomioNewton = function(a,b,n){ | ||
cumsum(choose(n,(0:n))*a^{n-(0:n)}*b^(0:n))[n+1] | ||
} | ||
binomioNewton(2,1,2) | ||
binomioNewton(3,4,14) | ||
``` | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters