
280 N.W.2d 375 (1979)
STATE of Iowa, Appellee,
v.
John Lee SANDERS, Appellant.
No. 62189.
Supreme Court of Iowa.
June 27, 1979.
John C. Wellman and Martha Shepard, Polk County-Des Moines Offender Advocate Office, Des Moines, for appellant.
Thomas J. Miller, Atty. Gen., William R. Armstrong and Lona J. Hansen, Asst. Attys. Gen., and Dan L. Johnston, Polk County Atty., for appellee.
Considered by REYNOLDSON, C. J., and UHLENHOPP, McCORMICK, McGIVERIN, and LARSON, JJ.
UHLENHOPP, Justice.
This appeal involves two problems which arose in a robbery prosecution.
The Polk County Attorney charged defendant John Lee Sanders with first-degree robbery in violation of sections 711.1 and 711.2, The Code 1979:

*376 711.1. A person commits a robbery when, having the intent to commit a theft, the person does any of the following acts to assist or further the commission of the intended theft or the person's escape from the scene thereof with or without the stolen property:
1. Commits an assault upon another.
2. Threatens another with or purposely puts another in fear of immediate serious injury.
3. Threatens to commit immediately any forcible felony.
It is immaterial to the question of guilt or innocence of robbery that property was or was not actually stolen.
711.2. A person commits robbery in the first degree when, while perpetrating a robbery, the person purposely inflicts or attempts to inflict serious injury, or is armed with a dangerous weapon. Robbery in the first degree is a class "B" felony.
The jury could find from the evidence that defendant drove two boys to Des Moines and dropped them off at a grocery store. One of the boys was armed with a gun. The boys entered the store and demanded money, but ran from the store when employees apparently frightened them. They ran in the direction of the car which defendant was driving very slowly down the street, and climbed in. Officers later apprehended defendant.
Defendant requested that the trial court submit as an included offense the crime of accessory after the fact under section 703.3(1) of the Code. The court refused.
The jury found defendant guilty as charged and answered an interrogatory affirmatively that defendant or an accomplice was in immediate possession and control of a firearm at the time of commission of the offense. Over defendant's objection, the trial court sentenced defendant to a mandatory five-year term because of the use of a gun in the crime.
Defendant appealed to this court where he raises the included offense and mandatory sentence issues.
I. Included offense. The trial information against defendant was in the form of a robbery charge against a principal. Defendant contends that under the evidence the trial court should have submitted as an included offense the crime which is provided by section 703.3(1) of the Code:
Any person having knowledge that a felony has been committed, and who does not stand in the relation of husband or wife to the person accused of committing the felony, who, with intent to prevent the apprehension of the accused person, harbors, aids or conceals the accused person, shall be guilty of an aggravated misdemeanor.
Defendant's contention has two aspects. One is the right of a defendant to argue to the fact finder as a matter of defense to the robbery charge that the evidence only shows defendant helped the robbers get away. No one denies defendant's right to urge this interpretation of the evidence upon the jury. The other aspect is the right of the prosecution to try to convict defendant of the aggravated misdemeanor of accessory after the fact. This is the problem presented.
The following new rules of criminal procedure bear on the problem of submitting included offenses. Rule 6 states in part:
1. Multiple offenses. When the conduct of a defendant may establish the commission of more than one public offense arising out of the same transaction or occurrence, the defendant may be prosecuted for each of such offenses. Each of such offenses may be alleged and prosecuted as separate counts in a single complaint, information or indictment, unless, for good cause shown, the trial court in its discretion determines otherwise. Where the public offense which is alleged carries with it certain lesser included offenses, the latter shall not be charged, and it is sufficient to charge that the accused committed the major offense.
2. Prosecution and judgment. Upon prosecution for a public offense, the defendant may be convicted of either the public offense charged or an included offense, but not both.

*377 3. Duty of court to instruct. In cases where the public offense charged may include some lesser offense it is the duty of the trial court to instruct the jury, not only as to the public offense charged but as to all lesser offenses of which the accused might be found guilty under the indictment and upon the evidence adduced, even though such instructions have not been requested.
Rule 21 states in paragraph 3:
3. Finding offense of different degree; included offenses. Upon trial of an offense consisting of different degrees, the jury may find the defendant not guilty of the degree charged in the indictment or information, and guilty of any degree inferior thereto, or of an attempt to commit the offense when such attempt is prohibited by law. In all cases, the defendant may be found guilty of any offense the commission of which is necessarily included in that with which the defendant is charged.
See also § 701.9, The Code.
Upon examination of these rules we conclude that the two-test process remains as before: the legal test (that "the elements of the lesser offense are an elementary part of the greater offense"), and the factual test (that "a factual basis [exists] in the record for submitting the included offense to the jury"). State v. Millspaugh, 257 N.W.2d 513, 516 (Iowa 1977); State v. Reese, 259 N.W.2d 771, 778 (Iowa 1977).
The case before us fails the first test. Aiding and abetting under section 703.3(1) contains at least one element which is dissimilar to any required for conviction of robbery under sections 711.1 and 711.2. The intent required under section 703.3(1) (to prevent apprehension) differs from the intent required under sections 711.1 and 711.2 (to commit a theft). Accessory after the fact "is a separate offense, and not a lesser included offense of robbery." Newkirk v. State, 222 So.2d 435, 436 (Fla.App. 1969) (per curiam). The trial court correctly refused to submit accessory after the fact to the jury as a crime with which defendant could be convicted in this prosecution.
II. Mandatory five years. Robbery is a forcible felony. § 702.11, The Code. Section 902.7 of the Code provides:
At the trial of a person charged with participating in a forcible felony, if the trier of fact finds beyond a reasonable doubt that the person is guilty of a forcible felony and that the person represented that he or she was in the immediate possession and control of a firearm, displayed a firearm in a threatening manner, or was armed with a firearm while participating in the forcible felony the convicted person shall serve a minimum of five years of the sentence imposed by law. A person sentenced pursuant to this section shall not be eligible for parole until he or she has served the minimum sentence of confinement imposed by this section.
Defendant contends that the mandatory five-year punishment does not apply to him unless he personally had the gun. The county attorney charged him as a principal pursuant to section 703.1, which provides:
All persons concerned in the commission of a public offense, whether they directly commit the act constituting the offense or aid and abet its commission, shall be charged, tried and punished as principals. The guilt of a person who aids and abets the commission of a crime must be determined upon the facts which show the part he or she had in it, and does not depend upon the degree of another person's guilt. (Emphasis added.)
Because section 703.1 deals with both guilt and punishment, we hold that not only the offender who holds the gun but also his aiders and abettors come within section 902.7. State v. Willis, 5 Wash.App. 441, 443, 487 P.2d 648, 650 (1971). In that case one robber had a gun. The court stated: "Defendants were both tried and convicted as principals. The question is whether both should receive the enhanced penalty. We believe they should. Otherwise, the provision `shall be punished as such' would have no meaning." See also State v. Jones, 324 N.E.2d 770, 772, 773 (Ohio App.1975) (per *378 curiam) (statutes precluded probation when "offense was committed while the offender was armed with a firearm or dangerous ordnance" and provided aider and abettor "shall be prosecuted and punished as if he were a principal offender"court held aider and abettor is to be punished as though he were the principal (italics in original)).
Authorities cited by defendant are not persuasive in view of our statutory language that aiders and abettors shall be "punished" as principals. Section 711.1 defining robbery speaks in terms of a person who assaults or threatens with intent to commit a theft, yet defendant, who did not personally do so, is guilty of that crime because of section 703.1. Similarly defendant, who did not hold the gun, is liable to the enhanced punishment of section 902.7 because of section 703.1.
The trial court decided these problems correctly.
AFFIRMED.
