Skip to main content
Updated from comments
Source Link
user692992
  • 268
  • 1
  • 7
  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.

  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.

  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.

  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then putencapsulating the prettinessalgorithmic properties of sleeping andyour code, while leaving the aesthetic properties (sleep, welcome message) in main() while maintaining the purity of your algorithm. Example:

uintmax_t num = get_next_fibbonaci(/*reference to struct storing state || values necessary for calculation*/);
  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.

  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.

  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.

  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main() while maintaining the purity of your algorithm.

  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.

  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.

  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.

  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function encapsulating the algorithmic properties of your code, while leaving the aesthetic properties (sleep, welcome message) in main(). Example:

uintmax_t num = get_next_fibbonaci(/*reference to struct storing state || values necessary for calculation*/);
added 6 characters in body
Source Link
Simon Forsberg
  • 59.4k
  • 9
  • 156
  • 309
  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.

    The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.

  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.

    Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.

  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.

    Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.

  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

    Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main() while maintaining the purity of your algorithm.

  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.
  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.
  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.
  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main() while maintaining the purity of your algorithm.

  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.

  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.

  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.

  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main() while maintaining the purity of your algorithm.

added 295 characters in body
Source Link
user692992
  • 268
  • 1
  • 7
  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.
  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.
  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.
  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main() while maintaining the purity of your algorithm.

  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.
  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.
  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.
  4. Finally, despite the mathematical purpose of the program, math.h is not needed.
  1. The Fibonacci series shall never yield non whole numbers; doubles are unnecessary and possibly computationally expensive. Try a uintmax_t. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit of uintmax_t.
  2. Your could have a classic I/O problem: output buffering. Try to put a \n in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can call fflush(stdout) after every printf(). While we're on the topic, your first two printf() statements can be combined. More info at this SO question.
  3. Obviously the Sleep() functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all.
  4. Finally, despite the mathematical purpose of the program, math.h is not needed.

Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main() while maintaining the purity of your algorithm.

added 104 characters in body
Source Link
user692992
  • 268
  • 1
  • 7
Loading
Source Link
user692992
  • 268
  • 1
  • 7
Loading