Skip to content

Instantly share code, notes, and snippets.

@jmramirezpro
Created March 9, 2016 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmramirezpro/72dbbcde774844d914f4 to your computer and use it in GitHub Desktop.
Save jmramirezpro/72dbbcde774844d914f4 to your computer and use it in GitHub Desktop.
/*
* 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