Here you can find the source of modulo(int x, int y)
public static int modulo(int x, int y)
//package com.java2s; //License from project: Creative Commons License public class Main { public static int modulo(int x, int y) { int z = x % y; return z < 0 ? z + y : z; }/*from w w w . j av a2 s. c o m*/ }