I'm having trouble writing a subroutine in a pseudocode program that has an input of a few numbers, checks if they're in arithmetic progression. I was thinking of doing something like this, (although I'm not sure if it would be the right way to go about it):
arithmeticProgression
input: alloc mem for integer as num1
alloc mem for integer as num2
alloc mem for integer as num3
alloc mem for integer as num4
output: boolean
alloc mem for boolean as arithmeticProgression
variable1 = num1-num2
variable2 = num2-num3
variable3 = num3-num4
if ((variable1==variable2) and variable2==variable3)
arithmeticProgression=true
else
arithmeticProgression=false
Aucun commentaire:
Enregistrer un commentaire