CodeLab Academy 📞 9936 6696
← List Python · Level 10: Algorithms Code · 100 points ← #998 #1000 →

#999. Josephus problem (k=7)

n people stand in a circle (1..n). Counting from 1, every 7-th person leaves. Find the number of the last person left. ### Input One integer n (1 ≤ n ≤ 1000). ### Output A number.

Examples

Input
799
Output
748
Input
700
Output
55

💡 You can solve it with Python, JavaScript or blocks. Read the input line by line with input(). Don't print a question (like input("Number: ")). Print exactly what the output asks for, nothing more.

🔒 You can solve the first 3 problems without an account. Sign up for free to solve this one!