Skip to content

Instantly share code, notes, and snippets.

@enricllagostera
Last active August 29, 2015 14:07
Show Gist options
  • Save enricllagostera/b51d01fda7d567851c4f to your computer and use it in GitHub Desktop.
Save enricllagostera/b51d01fda7d567851c4f to your computer and use it in GitHub Desktop.
Crie um script que conte quantos múltiplos de um número inteiro divisor (definido no Inspector) existem de 0 a 1000 e exiba o resultado ao final.
using UnityEngine;
using System.Collections;
public class ContagemMultiplos : MonoBehaviour
{
// editavel no Inspector
public int divisor;
void Start ()
{
int multiplos = 0;
for (int num = 0; num < 1000; num++)
{
if (num % divisor == 0)
{
multiplos++;
}
}
print(multiplos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment