From e8427bfd008be233aadea49e89075451c8a9ceee Mon Sep 17 00:00:00 2001 From: izabera Date: Sat, 6 Feb 2016 15:25:35 +0100 Subject: [PATCH] use unsigned long with factor --- toys/other/factor.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/toys/other/factor.c b/toys/other/factor.c index 570270ed8..8aa1d9350 100644 --- a/toys/other/factor.c +++ b/toys/other/factor.c @@ -19,7 +19,7 @@ config FACTOR static void factor(char *s) { - long l, ll; + unsigned long l, ll; for (;;) { char *err = s; @@ -27,14 +27,14 @@ static void factor(char *s) while(isspace(*s)) s++; if (!*s) return; - l = strtol(s, &s, 0); + l = strtoul(s, &s, 0); if (*s && !isspace(*s)) { error_msg("%s: not integer", err); return; } - printf("%ld:", l); + printf("%lu:", l); // Negative numbers have -1 as a factor if (l < 0) { @@ -44,7 +44,7 @@ static void factor(char *s) // Nothing below 4 has factors if (l < 4) { - printf(" %ld\n", l); + printf(" %lu\n", l); continue; } @@ -59,11 +59,11 @@ static void factor(char *s) long lll = ll*ll; if (lll>l || lll1) printf(" %ld", l); + if (l>1) printf(" %lu", l); break; } while (!(l%ll)) { - printf(" %ld", ll); + printf(" %lu", ll); l /= ll; } }