Loop on script

Hey, I made a script for object to change colors. so when I press E on keyboard it change the color of the object according to the numbers of color i defined. the problem is that I don’t know how to make it repeat on the process. lets say I made 3 colors. at the beginning it shows me the first color, by pressing E it change to the second color, another press on E and it change to the third color and that’s it, after pressing again on E nothing happening. how can I make it to return to the first color by the fourth click, and loop the process? thanks.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class colorchNGE : MonoBehaviour
{
    public Material[]Materials;
    public Renderer rend;


    private int index = 1;


    // Start is called before the first frame update
    void Start()
    {
        rend = GetComponent<Renderer>();
        rend.enabled = true;

    }

    private void Update()
    {

        if (Materials.Length == 0)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            index += 1;
        }
        print(index);
        rend.sharedMaterial = Materials[index - 1];

    }

}

Change this

private int index = 1;

To this:

private int index = 0;

And this:
rend.sharedMaterial = Materials[index - 1];to thisrend.sharedMaterial = Materials[index];

Then add this around line 29:

        if (Input.GetKeyDown(KeyCode.E))
        {
            index += 1;
            index %= Materials.Length;
        }

This is the integer modulus operator and it will make the index loop back around to 0 after reaching the end of the array.

the modulo operator.

        if (Input.GetKeyDown(KeyCode.E))
        {
            index = (index+1)%materials.Length;
        }