Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Polidivisible
#include <stdio.h> #define mensaje1 printf("%lu ES un numero POLIDIVISIBLE\n",numero) #define mensaje2 printf("%lu NO ES un numero POLIDIVISIBLE\n",numero) unsigned short esPolidivisible(unsigned long); unsigned short calcularLargo(unsigned long); int main() { unsigned long numero; do { scanf("%lu", &numero); if (numero == 0) break; esPolidivisible(numero) ? mensaje1 : mensaje2; } while (1); printf("FIN"); return 0; } unsigned short esPolidivisible(unsigned long copiaNumero) { unsigned short largo = calcularLargo(copiaNumero); unsigned short i; for (i = largo ; i >= 2 ; i--) { if (copiaNumero % i != 0) return 0; else copiaNumero /= 10; } return 1; } unsigned short calcularLargo(register unsigned long copiaNumero) { unsigned short largo = 0; while (copiaNumero != 0) { largo++; copiaNumero /= 10; } return largo; }
run
|
edit
|
history
|
help
0
Project 3 Part 1 v1.0
Project 3 part 2 Book v10.1
Vereinfachung
vetor mult
asasas
fork
WrongWay reversible iterator Copyright(C) 2016 Henry Kroll III www.thenerdshow.com
printing numbers without using loop
MATRICES DE CADENAS CON PUNTEROS
Coba