How to resolve the algorithm McNuggets problem step by step in the Dyalect programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm McNuggets problem step by step in the Dyalect programming language
Table of Contents
Problem Statement
Calculate (from 0 up to a limit of 100) the largest non-McNuggets number (a number n which cannot be expressed with 6x + 9y + 20z = n where x, y and z are natural numbers).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm McNuggets problem step by step in the Dyalect programming language
Source code in the dyalect programming language
func mcnugget(limit) {
var sv = Array.Empty(limit + 1, false)
for s in 0^6..limit {
for n in s^9..limit {
for t in n^20..limit {
sv[t] = true
}
}
}
for i in limit^-1..0 {
if !sv[i] {
print("Maximum non-McNuggets number is \(i)")
return
}
}
}
mcnugget(100)
You may also check:How to resolve the algorithm Empty program step by step in the VAX Assembly programming language
You may also check:How to resolve the algorithm AKS test for primes step by step in the PL/I programming language
You may also check:How to resolve the algorithm Conditional structures step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Hello world/Newbie step by step in the Zoomscript programming language
You may also check:How to resolve the algorithm Yin and yang step by step in the JavaScript programming language