Not passing a test case

public void appendLastN(int n) throws Exception {
int N=this.size();
n=n%N;
Node thead=this.head;
Node prev=this.head;

	Node curr=prev.next;
	for(int i=0;i<N-n-1;i++){
		prev=curr;
		curr=curr.next;
	}
	prev.next=null;
	Node temp=curr;
	while(temp.next!=null){
		temp=temp.next;
	}
	temp.next=thead;

	this.head=curr;

}

Hey @Vipin_coder
try for this input:
4
1 2 3 4
4
correct output :
1 2 3 4