NosuchElement exception at line 7

import java.util.*;
public class Main {
static long x=0;
static long y=0;
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long a=(long)n;
long m=1000000007;
moduloIverse(a,m);
System.out.println(x);
}
static void moduloIverse(long a,long b){
if(b==0){
x=1;
y=0;
return;
}
moduloIverse(b,a%b);
long cx=y;
long cy=x-(a/b)*y;
x=cx;
y=cy;
}
}

@Affan-Mokarram-202031887744398
NoSuchElementException indicates that the element being requested does not exist. so try to check your loops if they are running for more iterations than needed