Skip to main content
edited title
Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

Creating a function that checks whether input is an integer (in the mathematicamathematical sense)

deleted 24 characters in body
Source Link
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

A question regarging creating Creating a function that checks whether input is an integer (in the mathematica sense)

I am creating an alternative function of IntegerQ[] function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm gonna use it in another code. My code looks like;



    IntQ[n_] := Block[{}, GP = 0;
      {j = 0;
       If[n >=>= 0,
            For[i = n, i >> 0, i--, j++],
            For[i = (-n), i >> 0, i--, j++]]};
      {If[j == n, True, False]};];
  ]

It is not working. I just want to know where is the problem, why the problem is causing and how to solve it? Generally IntegerQ[6] would return True as an output and in other function it wouldn't return anything but we can use that value actually. So that's where my problem is.

A question regarging creating a function

I am creating an alternative function of IntegerQ[] function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm gonna use it in another code. My code looks like;



    IntQ[n_] := Block[{}, GP = 0;
      {j = 0;
       If[n >= 0,
            For[i = n, i > 0, i--, j++],
            For[i = (-n), i > 0, i--, j++]]};
      {If[j == n, True, False]};]

It is not working. I just want to know where is the problem, why the problem is causing and how to solve it? Generally IntegerQ[6] would return True as an output and in other function it wouldn't return anything but we can use that value actually. So that's where my problem is.

Creating a function that checks whether input is an integer (in the mathematica sense)

I am creating an alternative function of IntegerQ[] function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm gonna use it in another code. My code looks like;

IntQ[n_] := Block[{}, GP = 0;
  {j = 0;
   If[n >= 0,
        For[i = n, i > 0, i--, j++],
        For[i = (-n), i > 0, i--, j++]]};
  {If[j == n, True, False]};
  ]

It is not working. I just want to know where is the problem, why the problem is causing and how to solve it? Generally IntegerQ[6] would return True as an output and in other function it wouldn't return anything but we can use that value actually. So that's where my problem is.

Source Link

A question regarging creating a function

I am creating an alternative function of IntegerQ[] function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm gonna use it in another code. My code looks like;



    IntQ[n_] := Block[{}, GP = 0;
      {j = 0;
       If[n >= 0,
            For[i = n, i > 0, i--, j++],
            For[i = (-n), i > 0, i--, j++]]};
      {If[j == n, True, False]};]

It is not working. I just want to know where is the problem, why the problem is causing and how to solve it? Generally IntegerQ[6] would return True as an output and in other function it wouldn't return anything but we can use that value actually. So that's where my problem is.