Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

# 9. RECURSIVE METHOD. Write a function which returns all the vowels which do no

ID: 3832965 • Letter: #

Question

# 9. RECURSIVE METHOD. Write a function which returns all the vowels which do not appear
# in the word that is passed as a parameter
#
# for example,
#
# >>> absent_vowels('computer')
# 'ai'
# >>> absent_vowels('science')
# 'aou'
#
# Here I suggest that you use an optional parameter, "vowels",
# whose default value is 'aeiou'. Recursive calls should
# have 2 parameters: the word, and the vowels which have not
# yet been found in the word

def absent_vowels(word, vowels = 'aeiou'):
if vowels == '': # base case
return ''
elif False: # recursive case 1: replace "False"
pass
else: # recursive case 2
pass
  
# 10. RECURSIVE METHOD. Write a function called is_prime. It is passed a parameter n
# and returns True is n is a prime number or False otherwise.
# Recall that a number n is prime if only 1 and n divide evenly
# into n.

# i is an optional parameter whose default value is 2
# recursive calls to is_prime should pass 2 parameters

def is_prime(n, i=2):
pass

Explanation / Answer

10) import java.util.*;

public class CheckPrime{

static int prime(int n,int i)
{
if(i < n)
{
if(n % i != 0)
{
return(prime(n, ++i));
}
else
{
return 0;
}
}
return 1;
}
public static void main(String []args){
int n;
int check;
System.out.println("Please enter the number you want to check");
Scanner s = new Scanner(System.in);
n = s.nextInt();
check = prime(n,2);
  
if(check == 1)
{
System.out.println("Number is prime");
}
  
else
{
System.out.println("Number is not prime");
}
}
}