Question

(2.5 pts] Write the recursive function thirtyTwos(n) that takes an integer greater or equal to 0 and returns an integer that

In Python 3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 - def thirtyTwos(n): 3- if n < 10: # base case when n has less than 2 digits return 0 # condition for 32 if n % 10 == 2 and

CODE

def thirtyTwos(n):
  
if n < 10: # base case when n has less than 2 digits
return 0
  
# condition for 32
if n % 10 == 2 and (n//10) % 10 == 3:
return 1 + thirtyTwos(n//10)
  
# 32 is not there
return thirtyTwos(n//10)
  
# sample run
print(thirtyTwos(132432601))

#Please up vote

Add a comment
Know the answer?
Add Answer to:
In Python 3 (2.5 pts] Write the recursive function thirtyTwos(n) that takes an integer greater or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT