Answered by:
PYTHAGOREAN THEOREM
Question

I am trying to write a program to calculate if there are any whole numbers in a Pythagorean theorem where A and B are equal (a*a)+(a*a)=c squared and the square root of c is also a whole number. it is simple program to write I know, but how do I write a "IF Then" that would only give a whole number without rounding it off? if (c=math.integer) then... or if (c=math.wholenumber) then...?
Answers

You can use If c=Math.round(c) Then
Jan [ WhTurner ] The Netherlands
 Proposed as answer by Nonki TakahashiModerator Thursday, June 29, 2017 4:35 PM
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Monday, July 10, 2017 8:02 AM

I think it is fairly easy to prove algebraically that it is not possible:
a*a + a*a = c*c
c = sqrt(2)*a => sqrt(2) = c/a
sqrt(2) is irrational, therfore a and c cannot be integer numbers.
Fermat's last theorem is a completely different matter.... Edited by litdevModerator Sunday, June 25, 2017 6:44 PM
 Proposed as answer by Nonki TakahashiModerator Thursday, June 29, 2017 4:35 PM
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Monday, July 10, 2017 8:02 AM

If A and B are not equal, there are many a,b,c whole number sets that satisfy (a*a)+(b*b)=(c*c). In this situation, you can use:
If Math.Floor(c) = c Then ' c is whole number EndIf
Nonki Takahashi
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Monday, July 10, 2017 8:02 AM
All replies

You can use If c=Math.round(c) Then
Jan [ WhTurner ] The Netherlands
 Proposed as answer by Nonki TakahashiModerator Thursday, June 29, 2017 4:35 PM
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Monday, July 10, 2017 8:02 AM

I think it is fairly easy to prove algebraically that it is not possible:
a*a + a*a = c*c
c = sqrt(2)*a => sqrt(2) = c/a
sqrt(2) is irrational, therfore a and c cannot be integer numbers.
Fermat's last theorem is a completely different matter.... Edited by litdevModerator Sunday, June 25, 2017 6:44 PM
 Proposed as answer by Nonki TakahashiModerator Thursday, June 29, 2017 4:35 PM
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Monday, July 10, 2017 8:02 AM

If A and B are not equal, there are many a,b,c whole number sets that satisfy (a*a)+(b*b)=(c*c). In this situation, you can use:
If Math.Floor(c) = c Then ' c is whole number EndIf
Nonki Takahashi
 Marked as answer by Ed Price  MSFTMicrosoft employee, Owner Monday, July 10, 2017 8:02 AM