Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

hanged example

// def Function(x, List y) {
//     multres = 1;
//     for (i = 0; i<y.size(); i++) {
//         multres *= y.get(i);
//         println multres
//     }
//     multres = 1;
//     y.each {multres = it * multres}
//     println multres;
// }

def Mult (y, i) {
    while(i >= 1) {
        println i;
        // println y.get(0);
        //println y[i-1];
        //y[i-1] = y.get(i-1) * y.get(i);
        //y[i].remove();
        //i--;
    }
}

def x = 1;
List y = [1, 2, 3];

public void main() {
    //Function(2, [1, 2, 3]);
    y = [1, 2, 3, 4];
    i = y.size;
    Mult(y, i);
}

main();
//
//
// int mul(int a, int b)
// {
//     if (b == 1)
//         return a;
//     else
//         return a + mul(a, b - 1);
// }

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.