csci4061/lab01-code/collatz/collatz_main.c
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

21 lines
513 B
C

#include <stdio.h>
#include "collatz.h"
int main(int argc, char **argv){
int nstart;
printf("Enter the starting integer: ");
scanf("%d", &nstart);
int nnext = collatz_next(nstart);
printf("The next value in the Collatz sequence is %d\n",nnext);
int verbose;
printf("Show output of steps (0:NO, any other int: yes): ");
scanf("%d", &verbose);
int steps = collatz_steps(nstart,verbose);
printf("The starting value %d converged to 1 in %d steps\n",
nstart,steps);
return 0;
}