2^24 - Challenge - Unity C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PowerTest : MonoBehaviour
{
	public int a = 2;
	public int e = 24;
	int b;

	private void Start()
	{
		b = a;
		float p = Mathf.Pow(a, e);

		for (int i = 1; i < e; i++)
		{
			a = a * b;
		}
		Debug.Log(a);
		Debug.Log(p);
	}
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PowerTest : MonoBehaviour
{
	public int a = 2, e = 24;
	int b;

	private void Start()
	{
		b = a;
		float p = Mathf.Pow(a, e);

		for (int i = 1; i < e; i++)
		{
			a = a * b;
		}
		Debug.Log(a.ToString("n"));
		Debug.Log(p.ToString("n"));
	}
}


Very good!

Privacy & Terms