# [C (gcc)], <s>87</s> <s>86</s> 84 bytes

Saved a byte thanks to the man himself [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)!!!   

<!-- language-all: lang-c -->

    i;q;p;m;f(b){for(p=m=b;p|!q;++m)for(q=p=i=1;++i<m;)q=m%i<1?p=0,q&&b*~-b*~b%i:q;--m;}

[Try it online!][TIO-kg8lo137]

[C (gcc)]: https://gcc.gnu.org/
[TIO-kg8lo137]: https://tio.run/##bVFdb4IwFH33V3QkGKqXjFKrsNrtYdmvUB8EYWuyIl9ZyBz76@wiqFuypjfl3J5z2h5i9zWOu07LQubSyNSJ6Ck9lk6ujIpk/nVXyPnc0L5VqFxpxRDrtZG0UMbWa/aUKw@K6TSafbtYka0fCum6Rradzmpi9jpz6OQ0ITj6Rp1UdbXZEUVOPghYAvOA@eCvgPvAF8BXEOAMIAixz7A4@F7YyqtD0uRJXCeH0UTAYmDigkAI4ALYMuxxyMbJOEeOAD@4OMVv@3JGysHE2jYv/rYJn7GEBeQ35taowAyI019AZ4ekQZknx881qfRnckyd8@Po/YhmA5QEE@t5lAwxXB5CIjQZ8jjv7@R1Oy@RkDqWfSDuI8EbRVT@0ZZJ/bF/R33/x/7V2dU2Q@FAxHVzkahbgsOxu9GgnbTdDw "C (gcc) – Try It Online"  

Port of my [Python answer](https://codegolf.stackexchange.com/a/213463/9481).