Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //prints numbers as required by richard.
- //Tomas Donovic 27/3/
- #include <stdio.h>
- #include <stdlib.h>
- int printWondrous (int start);
- int main(){
- printWondrous(3);
- return EXIT_SUCCESS;
- }
- int printWondrous (int start){
- int currentval = start;
- printf("%d ",currentval);
- int counter = 1;
- while(currentval > 1){
- if((currentval % 2) != 0){
- currentval = currentval * 3;
- currentval ++;
- }else{
- currentval = currentval / 2;
- }
- printf("%d ",currentval);
- counter ++;
- }
- printf("\n");
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment