Created
March 9, 2016 11:13
-
-
Save jmramirezpro/72dbbcde774844d914f4 to your computer and use it in GitHub Desktop.
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
/* | |
* FactoresPrimos.c | |
* Ejercicios del Podcast Codigo Fuente - Programa 025 | |
* Escribe un programa que lea un número entero y lo descomponga en factores primos. | |
* Creado el 8 de mar. de 2016 | |
* Author: jmramirez | |
*/ | |
#include <stdio.h> | |
int main(void) | |
{ | |
int numero; | |
int factorPrimo; | |
printf("Introduce un número:"); | |
scanf("%d",&numero); | |
factorPrimo = 2; | |
printf("%d = ", numero); | |
while (factorPrimo <= numero) { | |
if ((numero % factorPrimo) == 0){ | |
printf("%d ", factorPrimo); | |
numero = numero / factorPrimo; | |
}else{ | |
factorPrimo++; | |
} | |
} | |
printf("\n"); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment