Skip to main content
Rollback to Revision 4 - Edit approval overridden by post owner or moderator
Source Link
Nike Dattani
  • 837
  • 1
  • 7
  • 25

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


Preamble

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a librarywithout using a library) to do the basic math that simple calculators can do?


Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


 

Related questions based on prior research:

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used muchare not used much, that they would be considered "bloatbloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a library) to do the basic math that simple calculators can do?


Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


 

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used much, that they would be considered "bloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


Preamble

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a library) to do the basic math that simple calculators can do?

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used much, that they would be considered "bloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).
Don't "bury the lede". Put the question at the top, and then the notes and clarifications at the bottom. Clean up the formatting.
Source Link

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


Preamble

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a librarywithout using a library) to do the basic math that simple calculators can do?


Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.

 

Related questions based on prior research:

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used muchare not used much, that they would be considered "bloatbloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


Preamble

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a library) to do the basic math that simple calculators can do?

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used much, that they would be considered "bloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a library) to do the basic math that simple calculators can do?


Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.

 

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used much, that they would be considered "bloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).
Mod Moved Comments To Chat
Question Protected by Michael Homer
deleted 511 characters in body
Source Link
Nike Dattani
  • 837
  • 1
  • 7
  • 25

When I first took a course onNote 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming with Javalanguages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I remember being shockedagree that to calculatethis joke is clever, it's unlikely that the factorialdevelopers of an integer, we wouldJava intentionally didn't include a factorial function so that CS teachers could have something to write our own functionteach, such asso this isn't the following one:type of answer I'm seeking.

public static int factorial(int n){    
      if (n == 0)    
        return 1;    
      else    
        return(n * factorial(n-1));    
     }

Preamble

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and have the computer program or script do what the user would expectfor $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for factorials, or at least square roots and other simple functions.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a librarywithout using a library) to do the basic math that simple calculators can do?

Related questions:

Before asking this I checked for a duplicate on this site, and the closest question I found was this one: Is there any particular reason to only include 3 out of the 6 trigonometry functions?, but the answers to that do not answer the question here.

Also on the Computer Science Educators Stack Exchange, there's the question "Why programming languages does not have factorial function?" which offers answers such as:

Related questions based on prior research:

  • such functions are not used muchIs there any particular reason to only include 3 out of the 6 trigonometry functions? (that might be true, but they're common enoughbut the answers to be on most high-school calculators since at leastthat do not answer the 1990squestion here),.
  • avoiding "bloat"Why programming languages does not have factorial function? (but including a handful of canonicalthe answers say that such functions isn't much bloatare not used much, that they would be considered "bloat", and the multiplication operationthat language designers want to avoid putting a flag in the ground that says "this is how it's done"; however my opinion is offered in most ofthat these languages even though a program could be writtenfunctions are common enough to do it using addition, just like a programming can be made to do a factorial function using multiplication),
  • avoiding putting a flagincluded in the ground that says "this is how it's done" (but again, these languages usuallypocket calculators which have fewer KB of RAM than a built-in multiplication methodcomputer, withso they are not much "bloat", and if there's already a flag in the ground for how it's done,multiplication and it doesn't require much sophistication or "maintenance" or complex/intractable consideration of standards, to include a pretty good factorial or square root function, just like they already haveexponentiation I don't see why there can't be one for sin(x) and cos(x) functionsor factorials).

When I first took a course on programming with Java, I remember being shocked that to calculate the factorial of an integer, we would have to write our own function, such as the following one:

public static int factorial(int n){    
      if (n == 0)    
        return 1;    
      else    
        return(n * factorial(n-1));    
     }

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, and have the computer program or script do what the user would expect. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for factorials, or at least square roots and other simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a library) to do the basic math that simple calculators can do?

Related questions:

Before asking this I checked for a duplicate on this site, and the closest question I found was this one: Is there any particular reason to only include 3 out of the 6 trigonometry functions?, but the answers to that do not answer the question here.

Also on the Computer Science Educators Stack Exchange, there's the question "Why programming languages does not have factorial function?" which offers answers such as:

  • such functions are not used much (that might be true, but they're common enough to be on most high-school calculators since at least the 1990s),
  • avoiding "bloat" (but including a handful of canonical functions isn't much bloat, and the multiplication operation is offered in most of these languages even though a program could be written to do it using addition, just like a programming can be made to do a factorial function using multiplication),
  • avoiding putting a flag in the ground that says "this is how it's done" (but again, these languages usually have a built-in multiplication method, with a flag in the ground for how it's done, and it doesn't require much sophistication or "maintenance" or complex/intractable consideration of standards, to include a pretty good factorial or square root function, just like they already have sin(x) and cos(x) functions).

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without calling a library (square roots, logarithms, trigonometric functions, factorials, etc.).

Note 2: Comments and answers have said things like "by providing a factorial out-of-the-box you'd deprive CS teachers of their favorite recursive-programming example". While I agree that this joke is clever, it's unlikely that the developers of Java intentionally didn't include a factorial function so that CS teachers could have something to teach, so this isn't the type of answer I'm seeking.


Preamble

I understand that not all programming languages can be like MATLAB, which by default allow users to write factorial(10) for 10!, sqrt(10) and for $\sqrt{10}$. Indeed, MATLAB, Mathematica, Maple, and other similar platforms, take up considerably more hard drive space than most compilers, even when combined with the space taken up by a typical heavy-weight IDE.

However, even some of the least sophisticated calculators have a button for these simple functions.

Why would so many languages like Java and C++ (see this StackOverflow thread if interested) not have a built-in way (i.e. without using a library) to do the basic math that simple calculators can do?

Related questions based on prior research:

  • Is there any particular reason to only include 3 out of the 6 trigonometry functions? (but the answers to that do not answer the question here).
  • Why programming languages does not have factorial function? (the answers say that such functions are not used much, that they would be considered "bloat", and that language designers want to avoid putting a flag in the ground that says "this is how it's done"; however my opinion is that these functions are common enough to be included in pocket calculators which have fewer KB of RAM than a computer, so they are not much "bloat", and if there's already a flag in the ground for multiplication and exponentiation I don't see why there can't be one for sin() or factorials).
Became Hot Network Question
added 31 characters in body
Source Link
Nike Dattani
  • 837
  • 1
  • 7
  • 25
Loading
deleted 170 characters in body
Source Link
Nike Dattani
  • 837
  • 1
  • 7
  • 25
Loading
Source Link
Nike Dattani
  • 837
  • 1
  • 7
  • 25
Loading