View averiguar_host.go
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
package main | |
import ( | |
"encoding/json" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"strings" | |
) |
View mcm.java
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
public static int minimoComunMultiplo(int a, int b) { | |
// Y ahora aplicamos la fórmula que dice: | |
// MCM(a, b) = (a * b) / MCD(a, b) | |
return (a * b) / maximoComunDivisor(a, b); | |
} |
View mcd.java
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
public static int maximoComunDivisor(int a, int b) { | |
int temporal;//Para no perder b | |
while (b != 0) { | |
temporal = b; | |
b = a % b; | |
a = temporal; | |
} | |
return a; | |
} |
View mcd.java
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
public class Main { | |
public static void main(String[] args) { | |
int a = 50; | |
int b = 120; | |
int mcd = maximoComunDivisor(a, b); | |
System.out.printf("El MCD de %d y %d es %d\n", a, b, mcd); | |
int mcdRecursivo = maximoComunDivisorRecursivo(a, b); | |
System.out.printf("El MCD de %d y %d (con recursividad) es %d\n", a, b, mcdRecursivo); | |
} |
View mcdRecursivo.java
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
public static int maximoComunDivisorRecursivo(int a, int b) { | |
if (b == 0) return a; | |
return maximoComunDivisorRecursivo(b, a % b); | |
} |
View mcd.java
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
public static int maximoComunDivisor(int a, int b) { | |
int temporal;//Para no perder b | |
while (b != 0) { | |
temporal = b; | |
b = a % b; | |
a = temporal; | |
} | |
return a; | |
} |
View translator.java
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
/* | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ |
View use.java
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
public static void main(String[] args) { | |
String originalText = "parzibyte.me"; | |
System.out.println("Original text: " + originalText); | |
String translatedText = textToBinary(originalText); | |
System.out.println("In binary, it is: " + translatedText); | |
System.out.println("-----------------"); | |
View binaryToText.java
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
public static String binaryToText(String binaryText) { | |
String[] binaryNumbers = binaryText.split(" "); | |
String text = ""; | |
for (String currentBinary : binaryNumbers) { | |
int decimal = binaryToDecimal(currentBinary); | |
char letra = (char) decimal; | |
text += letra; | |
} |
View textToBinary.java
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
public static String textToBinary(String originalText) { | |
String binaryText = ""; | |
for (int i = 0; i < originalText.length(); i++) { | |
char currentChar = originalText.charAt(i); | |
int ascii = (int) currentChar; | |
String binary = decimalToBinary(ascii); | |
binaryText += binary + " "; | |
} | |
return binaryText; | |
} |
NewerOlder